MSaudi
MSaudi

Reputation: 4652

Giving different id to each marker "overlay" at google maps in Android

I want each marker on the map (Map View) with different id so that I can remove it or change its icon dynamically at run time.

How do we achieve that ?

Also please I want the best way to add many markers on the map without making it slow when moving it on taping over it.

Thanks in advance

Upvotes: 0

Views: 497

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007296

How do we achieve that ?

Subclass OverlayItem and store whatever you want in it, using that instead of the ordinary OverlayItem class for your items. For example, this sample project has a CustomItem subclass of OverlayItem that, among other things, draws different icons at runtime.

Also please I want the best way to add many markers on the map without making it slow when moving it on taping over it

Don't "add many markers" to an ItemizedOverlay, to the point where it is "when moving it on taping over it". ItemizedOverlay is designed for small numbers of items.

If you need lots of items, you will most likely need to create your own Overlay, where you can have more smarts about which subset of your items will be relevant at any given time.

Upvotes: 2

Related Questions