Android Maps-API v2: where are the Overlays?

无人久伴 提交于 2019-12-11 04:09:11

问题


I have already written an app that uses GoogleMaps Api v1 in Android. This app uses several Overlays (or ItemizedOverlays) which handle a bunch of things autonomously (ie. lazy loading markers, as I have a whole lot of them and adding them all at once will force the app to close). I also use them as an interface for the user: He can decide which overlays (or which kind of markers from his perspective) he wants to see. I add or remove these Overlays accordingly. Now I want to switch to the new maps-v2-api. The documentation makes no mention of Overlays, and it seems that one cannot extend Markers as they are final.

Am I forced to kind of emulate the previous maps behavior, to be able to add and remove Overlays which handle Markers themself? Does anyone know a reason why Google removed this useful facility, and forces any developer to completely rewrite the GoogleMaps related code? I like to know also a reason for making the Marker class final, thus preventing anyone to add something related to it? (solutions I see store a global HashMap with the marker as key, and the infos they need as value, which is - in my point of view, very ugly considering that markers may have different models which are related to them).


回答1:


Am I forced to kind of emulate the previous maps behavior, to be able to add and remove Overlays which handle Markers themself?

Yes.

Does anyone know a reason why Google removed this useful facility, and forces any dev to completely rewrite the GoogleMaps related code?

Google engineers probably know the reason.

All I know that, for simple scenarios, the new approach requires less code. Maps V1 requires overlays, and overlays are overkill for many apps.

I like to know also a reason for making the Marker class final, thus preventing anyone to add something related to it?

Because the Marker is used for IPC and is not really retained within your process. Pretty much anything you do with Maps V2 results in IPC calls, based on Cyril Mottier's research.



来源:https://stackoverflow.com/questions/14526482/android-maps-api-v2-where-are-the-overlays

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