Home › Forums › JavaScript › Center google map not working › Reply To: Center google map not working
September 9, 2014 at 3:27 am
#182320
Participant
It is because you are doing map.setCenter(marker.getPosition())
inside your setMarkers
function. So the map will center on every marker, which is why in the end it centers on USA, because that’s the last marker being added.
Just remove that line from setMarkers
and it will center correctly.