请帮忙。我尝试了一个代码,它应该在谷歌地图上用标记给出我当前的位置。但它不工作。我已经通过 DDMS 和 TELNET 提供了我的位置,但仍然处于黑暗中。我应该怎么办??代码是:
package com.chupamobile.android.googlemaps;
import android.location.Location;
public class GoogleMapsActivity extends MapActivity{
private MapView myMap;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myMap = (MapView) findViewById(R.id.mymap);
initMap();
initMyLocation();
}
/**
* Initialise the map and adds the zoomcontrols to the LinearLayout.
*/
private void initMap() {
//myMap = (MapView) findViewById(R.id.mymap);
View zoomView = myMap.getZoomControls();
//MapController mc = myMap.getController();
//mc.setZoom(16);
LinearLayout myzoom = (LinearLayout) findViewById(R.id.myzoom);
myzoom.addView(zoomView);
myMap.displayZoomControls(true);
}
/**
* Initialises the MyLocationOverlay and adds it to the overlays of the map
*/
private void initMyLocation() {
MyLocationOverlay myLocOverlay = new MyLocationOverlay(this, myMap);
myLocOverlay.enableMyLocation();
myLocOverlay.enableCompass();
myMap.getOverlays().add(myLocOverlay);
Toast.makeText(getApplicationContext(), "I am In"+myLocOverlay, Toast.LENGTH_LONG).show();
}
/*public void onLocationChanged(Location location){
if(location!=null){
GeoPoint point = new GeoPoint((int)(location.getLatitude()*1E6),(int)(location.getLongitude()*1E6));
MapController mc = myMap.getController();
mc.animateTo(point);
mc.setZoom(16);
}
}
*/
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}