Web Maps API: Better approach to different sized markers for different zoom levels?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Web Maps API: Better approach to different sized markers for different zoom levels?

Jordan Anderson
Hey all,

I have a set of markers for which I show a larger icon when the user
zooms in past a certain zoom level and a smaller icon when they zoom
out again. I accomplish this by maintaining an array of objects that
point to 2 different instances of CM.Marker each with it own instance
of CM.Icon. I have a method that hides one marker instance and shows
the other depending on the zoom level. From a memory perspective, this
seems somewhat expensive to me since I can have more than 100 markers
active at a given time (which means that it requires 200 instances of
CM.Marker).

Is there a way -- using some undocumented methods or properties -- to
swap an CM.Marker instance's CM.Icon out instead so I can reduce the
number of CM.Marker instances I'm dealing with?

Thanks,
Jordan
_______________________________________________
Dev site list
[hidden email]
http://lists.cloudmade.com/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Web Maps API: Better approach to different sized markers for different zoom levels?

Vladimir Agafonkin
Hi Jordan,

From the performance perspective, there's no overhead of having many instances if CM.Marker as long as they are not currently added to the map as DOM objects. So if you create 2 CM.Marker instances for one marker and do addOverlay and removeOverlay of either one instead of show/hide the performance should be the same as when swapping the icon (since such a method would do basically the same as add/removeOverlay).

On Fri, Sep 17, 2010 at 9:07 PM, Jordan Anderson <[hidden email]> wrote:
Hey all,

I have a set of markers for which I show a larger icon when the user
zooms in past a certain zoom level and a smaller icon when they zoom
out again. I accomplish this by maintaining an array of objects that
point to 2 different instances of CM.Marker each with it own instance
of CM.Icon. I have a method that hides one marker instance and shows
the other depending on the zoom level. From a memory perspective, this
seems somewhat expensive to me since I can have more than 100 markers
active at a given time (which means that it requires 200 instances of
CM.Marker).

Is there a way -- using some undocumented methods or properties -- to
swap an CM.Marker instance's CM.Icon out instead so I can reduce the
number of CM.Marker instances I'm dealing with?

Thanks,
Jordan
_______________________________________________
Dev site list
[hidden email]
http://lists.cloudmade.com/listinfo/dev



--
Vladimir Agafonkin
Front-End Architect, CloudMade
+380 93 745 44 61

_______________________________________________
Dev site list
[hidden email]
http://lists.cloudmade.com/listinfo/dev