Reputation: 17753
I am facing a problem of adding overlays. I want to add button which will toggle between normal and satelitte view, and some textView, which will display my actual coordinates and those will be updated on my location change. I tried to put there classic TextView, added into my map.java import for using GPS, and onLocationChanged I am trying to update TextView's, but no success. It must be done via Overlays, but I can't see, how to set on the screen my desired items - button with specific function and regularly updated textView. Any ideas?
THanks
edit:
int g=0;
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setEnabled(true);
mapView.setClickable(true);
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.toggle:
if (g!=1){
mapView.invalidate();
mapView.setSatellite(true);
mapView.invalidate();
g=1;
}else{
mapView.invalidate();
mapView.setSatellite(false);
mapView.invalidate();
}
break;
}
}
Upvotes: 1
Views: 5220
Reputation: 27455
You don't need a overlay for this. Just define you layout using a layout xml file with an RelativeLayout as root element.
With a relative layout you can place elements like TextViews or a Buttons on top of each other. So in your case you would first define the MapView in your layout file and then the elements you want to display on the MapView. Now all elements should be rendered in the upper left corner on top of each other. Using the attributes defined by the RelativeLayout you can now align your elements in the way you want. Have a look at the RealtiveLayout tutorial for a better understanding.
Upvotes: 3
Reputation: 7696
Here a some nice resources:
http://developer.android.com/resources/tutorials/views/hello-mapview.html
http://mobiforge.com/developing/story/using-google-maps-android
Efficient Map Overlays in Android Google Map
Hope you get an answer :-)
Upvotes: 1