StackTips
 1 minutes

How to add zoom controls to Android MapView

By Editorial @stacktips, On Sep 17, 2023 Android 2.28K Views

The following code snippet shows how to add zoom controls to Android MapView. We can achieve this by calling setBuiltInZoomControls(boolean) method.

MapView map = (MapView)findViewById(R.id.mapview);
map.setBuiltInZoomControls(true);

The above code snippet will add the zoom controls to the bottom-center of the MapView. The zoom controls only show up when you touch the screen, so you have to make sure that the map is clickable.

<com.google.android.maps.MapView
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:id="@+id/mapview"
       android:clickable="true"
       android:apiKey="your key">
</com.google.android.maps.MapView>
stacktips avtar

Editorial

StackTips provides programming tutorials, how-to guides and code snippets on different programming languages.