5

I have a sidebar on which I want to display all the markers which are placed on the Google Map. and when I change the Veiwport by dragging the map. The marker list should refresh.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Vishnu Sharma
  • 53
  • 1
  • 3

1 Answers1

7

To Get all the Markers first you have to find the Bounds of the current Viewport then you have to loop all the markers and see if they are contains in the bound. The following is a example.

var bounds =map.getBounds();

for(var i = 0; i < markers.length; i++){ // looping through my Markers Collection        
if(bounds.contains(markers[i].position))
 console.log("Marker"+ i +" - matched");
}
Shishir Raven
  • 188
  • 11
  • 2
    I believe the question was about how to get all the markers currently visible on the map - from the map itself. I don't know if that's possible though. – Kath Jun 14 '16 at 17:50