How to capture location from MapActivity

淺唱寂寞╮ 提交于 2019-12-20 05:23:28

问题


Given ...

  • An Activity that extends from MapActivity
  • Uses ItemizedOverlay to show some balloons on the map
  • ZoomControls are enabled

The ItemizeOverlay implements onTap(...) which works perfectly ok when tapping one of the overlay items.

The question is: How to identify a tap on another part of the map (with the intention of getting the location and center'ing on that point)


回答1:


You should be able to create an 'invisible' overlay (in the sense that you don't draw anything in onDraw) that sits at the front of the MapView's overlay list and in onTap, sets the map center with MapController.setCenter.

To quote the MapView.getOverlays documentation regarding overlay ordering:

Any Overlays in this list will be drawn (in increasing order) and will receive events (in decreasing order, until one returns true). If you modify the list, you will probably want to call View.postInvalidate() so that the change will be made visible to the user.



来源:https://stackoverflow.com/questions/1772584/how-to-capture-location-from-mapactivity

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