Modify Zoom Controls in MapView

I would like to change the predefined style of the zoom controls in my application so that they look like the new zoom controls in the Google Maps application. See below:

enter image description here

How can i do this? I looked around and found nothing.

Thanks in advance.

+5
android google-maps zoom android-mapview
source share
2 answers

You should have four images, namely:

  • Enlarge (+) enable / disable
  • Decrease (-) enable / disable

Place them in a MapView a ImageView or Button layout with a background image, as shown above.

Then you should assign onClickListeners, for example:

 zoomIn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mapView.getController.zoomIn() checkzoom(); } }); zoomOut.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mapView.getController.zoomOut() checkzoom(); } }); public void checkzoom() { if(mapView.getZoomLevel()==1) // dont know if 0 or 1, just wrote it { zoomOut.setEnabled(false); // or u can change drawable and disable click } if(mapView.getZoomLevel()==18) { zoomIn.setEnabled(false); // or u can change drawable and disable click } } 

EDIT: zoom inzoom out

+5
source share

I solved the problem this way: disabled the built-in zoom controls ( setBuiltInZoomControls(false) ), added my own buttons to the interface and added handlers for clicking on button events.

+5
source share

All Articles