How to catch a map panning | zooming finished event with Android SDK?

匆匆过客 提交于 2019-12-24 10:45:42

问题


I am looking for a way to receive events when a map finished panning or zooming or panning and zooming. Those events are not fired, afaik, from MapActivity in the SDK for Android 2.3.3 which I use. I tried the MapChange library, however, it forces you to use Handler in your MapActivity to ensure to that UI updates are processed on the UI thread; more information.

Question: Do you know of any support for such events by the Android Support Library e.g. by using FragmentActivity instead of MapActivity - I could not find an alternative solution by now.

Similar questions can be found here:

  • Android MapActivity on map movement
  • How to catch that map panning and zoom are really finished?

Edit: The MapChange library was updated some hours ago. I will check out what has been improved.


Edit: The MapChange library has been improved and works much more reliable now and is a good option! Please checkout the GitHub project for further information. However, I leave the question open since I am still interested whether one can do the same with existing components.


回答1:


You can use the GoogleMap.OnCameraChangeListener to assign a listener to the changing camera event. Handling that and other events is discussed in the Google Maps Android API documentation.




回答2:


Why is it a problem to use a Handler ? You can always post your UI changes to the main thread, why not do that ?

Someone on SO found a way to get a Fragment activity to contain a MapView by changing the support library code but it became too cumbersome for me to use and I reverted to a full-blown Map activity.




回答3:


For anyone still looking for an answer to this

googleMap.setOnCameraIdleListener {
                //Do your thing
            }

called when camera movement has ended



来源:https://stackoverflow.com/questions/11519381/how-to-catch-a-map-panning-zooming-finished-event-with-android-sdk

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