简体   繁体   English

如何将Google Map的标记居中而不在地图画布的中间

[英]how to center google map's marker not in the middle of the map canvas

map.setCenter(new google.maps.LatLng(locationX,locationY); 

if I do this way, google puts a marker in the center of map canvas. 如果我这样做,Google会在地图画布的中心放置一个标记。 I want that it will be not center, bot for example top right corner. 我希望它不会居中,例如右上角的机器人。 Is it possible? 可能吗?

Instead of setCenter, try the following 代替setCenter,请尝试以下操作

panTo(latLng:LatLng)

Changes the center of the map to the given LatLng. 将地图的中心更改为给定的LatLng。 If the change is less than both the width and height of the map, the transition will be smoothly animated. 如果更改小于地图的宽度和高度,则过渡将平滑地进行动画处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM