Rosko, thanks.

Is checking new markers against old ones in the array less "expensive"
than deleting all the markers and redrawing them?
In the first approach you'll have to take each new marker and try to
find it in the array.
In the worst case scenario the number of actions here will be the
number of markers power 2.
So 1,000 markers can cause 1,000,000 checks.
In the second approach you will only have to delete a 1,000 markers
and then draw a 1,000 more.


On May 31, 1:01 pm, Rossko <[email protected]> wrote:
> > I know I have to delete all the markers from the map before the new
> > markers are painted and I know I should probably be using
> > marker.setMap(null);.
> > I just don't know how and where to fit it in my code:
>
> You can't, unless you somehow remember which markers you put on the
> map in order to remove them later.
> The usual approach is to store added markers in an array.
> When you want to remove them all, iterate through the array and remove
> each, then clear the array.
>
> There are more sophisticated approaches, like checking 'new' markers
> against 'old' ones in your array so as to avoid removing/adding the
> same marker.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" 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/google-maps-js-api-v3?hl=en.

Reply via email to