> Thanks for the help. Cant get anything working right. I tried adding on the
> button clearMarkers(map, locations), didnt work.

What would be the value of 'map' and 'markers' at the time the button
is clicked?

'map' is defined, because you created a global variable called
'map' (by using var map; outside of any function) and you used that
variable to keep a reference to new google.maps.Map() in your
initialize() function.

But 'locations' isn't defined anywhere.

At the moment, you are not remembering the references to the markers
you create and place on the map.  If you don't remember them, you
can't remove them.  This is what Larry's suggestion is about - "an
array of your markers" is needed.

You could define a global variable which is an empty array, call it
what you like.

When you create markers, push each one into your array. setMarkers()
looks like a good place to do that.

Then have your button call clearMarkers(map,
theNameOfYourArrayOfMarkers)

-- 
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