Google Maps setCenter()

前端 未结 5 1384
予麋鹿
予麋鹿 2021-01-03 19:07

I\'m using google maps. In my code i\'ve used setCenter() function. My problem is that marker is always located on top left corner of map area (not at the center). Please te

5条回答
  •  孤独总比滥情好
    2021-01-03 19:10

    @phoenix24 answer actually helped me (whose own asnwer did not solve my problem btw). The correct arguments for setCenter is

    map.setCenter({lat:LAT_VALUE, lng:LONG_VALUE});
    

    Google Documentation

    By the way if your variable are lat and lng the following code will work

    map.setCenter({lat:lat, lng:lng});
    

    This actually solved my very intricate problem so I thought I will post it here.

提交回复
热议问题