Android MapView - custom Zoom buttons

淺唱寂寞╮ 提交于 2019-12-01 03:07:48

问题


do you know, if there is a way how to make custom zoom buttons in Android's mapView? Or there are only prepreared zoom controls?

Thanks

Hmyzak


回答1:


You can set the default zoom controls to false (mapView.setBuiltInZoomControls(false)), add some buttons that are drawn on top of the map and have each button have a listener for when they are pressed. The MapView allows you to set the zoom level. One of the buttons could do a mapView.getController().zoomOut(), the other could do a mapView.getController().zoomIn(). If for some reason you need to find the zoom level, you can do a mapView.getController().getZoomLevel(). The maximum zoom level can be found by using mapView.getController().getMaxZoomLevel(). In my experiences, this value was 21.

Here is the page for MapView documentation on its Google Code page.

Here you can read documentation on the MapController

EDIT: Updated solution to use zoomIn and zoomOut




回答2:


Rather than mapView.getController().setZoom() you should use mapView.getController().zoomIn() and mapView.getController().zoomOut(). It gives you animated zoom like google maps default zooming controls and also you don't need to take care of zoom level by yourself.

This has been discussed here



来源:https://stackoverflow.com/questions/6844184/android-mapview-custom-zoom-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!