![](/img/trans.png)
[英]Leaflet and MarkerCluster - don't perform clustering when there is a popup currently open?
[英]leaflet markercluster open popup on load
我的应用程序中包含以下代码,并且所有标记都添加到一个组中。我希望未加载到群集中的标记弹出窗口在加载地图时在其上显示弹出窗口。 (当标记以特定缩放级别加载时,属于聚类的一部分但未折叠到特定缩放级别上的聚类的标记)
var markers = [{
"latLong": [57.67, -3.89]
},
{
"latLong": [-4.4, -58.34]
},
{
"latLong": [35.79, 139.48]
}],
markerGroup = L.markerClusterGroup(),
marker;
markers.forEach(function (markerConfig, index) {
marker = new L.Marker(new L.LatLng(markerConfig.latLong[0], markerConfig.latLong[1]));
marker.bindPopup(index, {
"autoClose": false,
"closeOnClick": false
}).openPopup();
markerGroup.addLayer(marker);
});
clusterMap.addLayer(markerGroup);
我想要标记的openPopup()方法在加载地图时打开弹出窗口,在单击标记时将其打开。 请帮忙。
我找到了解决方案,诀窍是先将群集组添加到地图,然后将标记添加到组,然后在标记上调用openPopup。 因此,这只是调用函数的顺序问题。
var markers = [{
"latLong": [57.67, -3.89]
},
{
"latLong": [-4.4, -58.34]
},
{
"latLong": [35.79, 139.48]
}],
markerGroup = L.markerClusterGroup(),
marker;
clusterMap.addLayer(markerGroup);
markers.forEach(function (markerConfig, index) {
marker = new L.Marker(new L.LatLng(markerConfig.latLong[0], markerConfig.latLong[1]));
markerGroup.addLayer(marker);
marker.bindPopup(index, {
"autoClose": false,
"closeOnClick": flase
}).openPopup();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.