Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the proper way to change look of MapView zoom controls in Android?

Tags:

android

What is the proper way to change look of MapView zoom controls in Android?

I want to repoduce zoom button from new google maps.

enter image description here

like image 944
Alexey Zakharov Avatar asked Nov 15 '11 08:11

Alexey Zakharov


People also ask

What are the methods of zoom control in Android?

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.

Which method is used to display zoom control on Google map?

Want to add zoom controls to Android MapView? We can achieve this by calling setBuiltInZoomControls(boolean) method. map. setBuiltInZoomControls(true);

What is zoom level in Google map?

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.


Video Answer


1 Answers

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.

like image 166
sampathpremarathna Avatar answered Oct 10 '22 23:10

sampathpremarathna