Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Center google map not working

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #182189
    turquesodesk
    Participant

    Maybe i’m overlooking something? Center is not working. I know there’s a way to Auto center but it cuts Asia in two. I want America on the left and not in the middle as it shows up with auto center. Thank you in advance!

    Demo Here

    #182320
    Chromawoods
    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.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.