开发者

Android MapView - custom Zoom buttons

do you know, if there is a way how to make custom zoom buttons i开发者_如何学编程n Android's mapView? Or there are only prepreared zoom controls?

Thanks

Hmyzak


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜