如何防止传单拖动地图以适合标记弹出窗口? [英] How can i prevent leaflet from dragging the map to fit marker popups?
问题描述
当前,我们正在使用gmaps进行一个传单项目,但我遇到了一个小问题.
currently we are working on a leaflet-project with gmaps and i´ve got a little problem .
添加多个标记(每个都有一个弹出窗口)后,我们希望将其全部打开.
After adding multiple markers (with a popup each) we want to open them all.
为此,我正在使用以下安全代码:
To do so, i´m using the following peace of code:
L.Map = L.Map.extend({
openPopup: function(popup) {
// this.closePopup();
this._popup = popup;
return this.addLayer(popup).fire('popupopen', {
popup: this._popup
});
}
});
在页面加载时,一切正常.
On pageload everything works as expected.
但是失败场景在这里:
在pageload
之后,用户zooms in
和某些标记是用户的out of the view area
.
After pageload
the user zooms in
and some markers are out of the "view area"
of the user.
几秒钟后,网站加载了new position data
(用于标记)using a rest interface
.
few seconds later, the website loads new position data
(for the markers) using a rest interface
.
在传输位置数据后,我目前删除了所有标记,并在传输的位置重新创建它们并打开它们.
After position data transmitted, i currently remove all markers and recreate them at the transmitted positions and open them.
此marker.openPopup()
触发该map moves
触发该popup fits in the view area of the user
.
在这种情况下我怎么能prevent leaflet to drag the map
?
How can i prevent leaflet to drag the map
in this case?
推荐答案
我相信您指的是autoPan
属性?通过API:Set it to false if you don't want the map to do panning animation to fit the opened popup.
I believe you are referring to the autoPan
property? From the API: Set it to false if you don't want the map to do panning animation to fit the opened popup.
http://leafletjs.com/reference.html#popup
因此,在创建弹出窗口时,只需传递选项autoPan: false
So when creating your Popup, just pass in the option autoPan: false
这篇关于如何防止传单拖动地图以适合标记弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!