marker.setPosition() 当 infowindow 打开时将标记带入视图 - 如何停止这个?
marker.setPosition() when infowindow is open brings the marker into view - how to stop this?
我有 Google 个带有 Javascript API 的地图,上面只有一个标记。这个单个标记有一个信息窗口显示。
当我调用 marker.setPosition()
移动标记时,如果信息窗口打开并且标记在屏幕外,则地图会平移以将标记和信息窗口显示在视图中。
我怎样才能阻止这种行为?我想移动标记,但将其留在屏幕外,并将地图位置留在原处。
如果我关闭信息窗口,则调用 marker.setPosition()
不会平移地图。不需要的行为仅在信息窗口打开时发生。
默认情况下,信息 windows 将平移地图,以便它们在打开时完全可见。您可以在创建时在 google.maps.InfoWindow
上设置的 InfoWindowOptions
上将 disableAutoPan
设置为 true
。例如,您在哪里声明您的信息 window:
let infowindow = new google.maps.InfoWindow({
content: "Blah Blah Blah",
// other code ...
disableAutoPan: true
});
我有 Google 个带有 Javascript API 的地图,上面只有一个标记。这个单个标记有一个信息窗口显示。
当我调用 marker.setPosition()
移动标记时,如果信息窗口打开并且标记在屏幕外,则地图会平移以将标记和信息窗口显示在视图中。
我怎样才能阻止这种行为?我想移动标记,但将其留在屏幕外,并将地图位置留在原处。
如果我关闭信息窗口,则调用 marker.setPosition()
不会平移地图。不需要的行为仅在信息窗口打开时发生。
默认情况下,信息 windows 将平移地图,以便它们在打开时完全可见。您可以在创建时在 google.maps.InfoWindow
上设置的 InfoWindowOptions
上将 disableAutoPan
设置为 true
。例如,您在哪里声明您的信息 window:
let infowindow = new google.maps.InfoWindow({
content: "Blah Blah Blah",
// other code ...
disableAutoPan: true
});