I have successfully implemented diplaying of Google Maps in my application. When Android phone gets GPS signal, actual position is blinking but still I am on 开发者_开发技巧the whole map. I am having Google Map diplayed by:
public class map extends MapActivity{
MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapa);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setEnabled(true);
initMyLocation();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
private void initMyLocation() {
MyLocationOverlay myLocOverlay = new MyLocationOverlay(this, mapView);
myLocOverlay.enableMyLocation();
mapView.getOverlays().add(myLocOverlay);
}
}
I would like to add into map some other items, e.g. some text field, which shows me the actual coordinates, some button which will take me instantly to my coordinates with some default zoom. Is there any simple way, how to add theese components into my displayed Google Map?
Thx
You will need to use OverLays to do what you want. You can create an instance of OverLays and add it using MapView.getOverLays(). In your OverLay you can get the Geo Location andf using the onFocus you can zoom in and out. You don't need a textField to display your coordinates.OverLays will do that for you.
精彩评论