I cannot speak with regards to tile overlays, as I have not played with that portion of the API.
With respect to markers, AFAICT, you cannot set an ID -- the ID from getId() presumably is system-generated. If you do not need one of the other marker attributes (e.g., snippet), you could overload that and put an identifier in there. We also cannot subclass Marker, partly because it is final, and partly because the MarkerOptions structure does not allow us to specify any sort of factory. Hence, you cannot add an ID field to your own Marker subclass, the way we could subclass OverlayItem in Maps V1. The only other workaround that I have seen is to use a WeakHashMap<Marker, Something>, for looking up additional data on a per-Marker basis. The WeakHashMap will allow our Something objects to get garbage-collected after their corresponding Marker objects are. And, yes, this sucks. Cyril Mottier had similar complaints: http://android.cyrilmottier.com/?p=855 On Sat, Jan 5, 2013 at 8:52 AM, lbendlin <[email protected]> wrote: > In the olden days (API v1) I used to add views to maps, and tag the views > with their ids (from my database). Then I could find them on the map via > their tag. > > Now in the v2 API there seems no way to add views. The closest I can see is > to use groundoverlays. The documentation says they have an ID that I can > fetch via getId(). But I can't find anywhere how to SET the id. The same > applies to markers too. > > The reason for tagging markers/overlays is to be able to avoid adding them > again if they are already on the map, and to have the option to remove them > again later. I cannot keep individual assignments as I have thousands of > markers that could be placed on the maps (I do database queries depending on > the camera position and span etc) > > So how can I set the id of a marker or ground overlay when adding them to > the map? > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Här kan du ställa och svara på frågor om applikationsutveckling på Android: http://www.andglobe.com -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

