0

Possible Duplicate:
check if map markers are within selected bounds

I have couple hundreds markers, but for convenience, I would like to 'grey-out' some options for markers which are not currently visible on the map (they are on the map, but outside the currently viewed map boundaries.)

As a solution, I think that I need to loop over all my markers (I have an array, so this is not a problem), but I don't know how to check if marker is currently within visible boundaries.

Community
  • 1
  • 1
Andrew
  • 7,619
  • 13
  • 63
  • 117
  • 1
    http://stackoverflow.com/questions/6100514/google-maps-v3-check-if-marker-is-present-on-map second answer should be what you are looking for ;) – chsymann Jan 21 '13 at 22:46
  • @chsymann, Thank you add as official answer please! – Andrew Jan 21 '13 at 23:05

1 Answers1

2

You should use the following:

map.getBounds().contains(marker.getPosition())

It will return true if the marker is inside your map boundary, false otherwise.

chsymann
  • 1,640
  • 1
  • 15
  • 15