Sebastian Thomas
Sebastian Thomas

Reputation: 1324

How do I use removeMarker in GMaps.js to filter markers?

I'm using GMaps.js. I've added markers with JSON, and would like to filter (hide) some markers based on values in that JSON. Ie, hide all markers which don't have a value foo for property bar.

I'm able to use map.removeMarkers(), it just removes all markers, and I see in my console there is another method called removeMarker(), but I don't know how I'd specify a particular marker.

I know it's not the same library, but the documentation has been useful before, so I've been taking tips from the jQuery maps filtering documentation

Upvotes: 0

Views: 3134

Answers (1)

Darth Plagueis
Darth Plagueis

Reputation: 930

To use the map.removeMarker() method you need to keep track of your markers. and pass the marker you want to remove to the method. Other than that you can use map.map which returns the map object from google maps api, and you can use the google maps api methods.

Upvotes: 1

Related Questions