What is the proper way to change look of MapView zoom controls in Android?
I want to repoduce zoom button from new google maps.
In Android, Zoom Control is a class that has some set of methods that are used to control the zoom functionality. It has two buttons that are used to control the zoom functionality (ie Zoom In and Zoom Out). Zoom Control Class has been deprecated in API Version 29.
Want to add zoom controls to Android MapView? We can achieve this by calling setBuiltInZoomControls(boolean) method. map. setBuiltInZoomControls(true);
The Google Maps API provides map tiles at various zoom levels for map type imagery. Most roadmap imagery is available from zoom levels 0 to 18, for example. Satellite imagery varies more widely as this imagery is not generated, but directly photographed.
i have done this.the default controls come on the bottom of the map and i wanted it to be top of the map.i used this.
<com.google.android.maps.MapView
android:layout_below="@+id/layout_zoom"
android:id="@+id/mapview" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:clickable="true"
android:apiKey="key" />
<ZoomControls android:id="@+id/zoomControls" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true"></ZoomControls>
then in the MapActivity class set zoom controls
MapView mp = (MapView) findViewById(R.id.mapview);
ZoomControls zoomControls = (ZoomControls) findViewById(R.id.zoomControls);
zoomControls
.setOnZoomInClickListener(new ZoomControls.OnClickListener() {
public void onClick(View v) {
mp.getController().zoomIn();
}
});
zoomControls
.setOnZoomOutClickListener(new ZoomControls.OnClickListener() {
public void onClick(View v) {
mp.getController().zoomOut();
}
});
you can set this listeners to your own button also. hope it will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With