How to move the center position of google map

前端 未结 2 378
执笔经年
执笔经年 2021-01-12 09:44

I am creating a google map in a script with the following code -

var mapElement,
    parent,
    mapOptions,
    map,
    marker,
    latLong,
    openMarke         


        
2条回答
  •  情书的邮戳
    2021-01-12 10:28

    You can use .setCenter() to move the center of the map

    map.setCenter(marker.getPosition());
    

    Update

    Convert the LatLng with .fromLatLngToDivPixel() into a Point add an offset and convert it back into a LatLng with .fromDivPixelToLatLng()

提交回复
热议问题