Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Leaflet 从URL在标签上打开传单地图标记弹出窗口_Leaflet - Fatal编程技术网

Leaflet 从URL在标签上打开传单地图标记弹出窗口

Leaflet 从URL在标签上打开传单地图标记弹出窗口,leaflet,Leaflet,我正在将另一页上的链接中的一个latlng传递到我的地图。我的地图上有基于这个板条的标记。因此,我要传递的正是地图标记用来在地图上显示的内容 var hash = window.location.hash; var hashless = hash.replace("#", ""); var ll = hashless.split(",", 2); map.setView(new L.LatLng(ll[0], ll[1]), 14); 这是伟大的工作,但我正在努力让标记显示它的信息窗口。我想只

我正在将另一页上的链接中的一个latlng传递到我的地图。我的地图上有基于这个板条的标记。因此,我要传递的正是地图标记用来在地图上显示的内容

var hash = window.location.hash;
var hashless = hash.replace("#", "");
var ll = hashless.split(",", 2);
map.setView(new L.LatLng(ll[0], ll[1]), 14);
这是伟大的工作,但我正在努力让标记显示它的信息窗口。我想只有点击的链接是标记,显示它的弹出窗口。我可以直接缩放到标记,但无法使弹出窗口以合理的方式工作

我已经尝试了一些方法,但是map.getBounds()似乎是我应该使用的方法,除非您可以基于Lat/Lng识别标记。你能吗

我正在map.on函数中使用边界。。。。但这些活动似乎都没有真正奏效。本来以为加载就可以了,但是没有结果。。。视图重置、鼠标移动等。。。所有显示在这个简单的功能弹出窗口,但它不是真的任何好,因为它闪烁等。。。移动物体时:

map.on('viewreset', function () {
                // Construct an empty list to fill with onscreen markers.
                console.log("YA");
                var inBounds = [], bounds = map.getBounds();
                datalayer.eachLayer(function (marker) {
                    if (bounds.contains(marker.getLatLng())) {
                        inBounds.push(marker.options.title);
                        marker.openPopup();
                    }
                });
            });

如何将链接中的marker.openPopup()设置为传递给它的lat/lng处的当前标记?

您可能/理论上可以在包含所有标记的featureGroup中循环(
.eachLayer
),并通过检查
.getLatLng()的结果,使用匹配坐标识别标记
。您可能/理论上可以在包含所有标记的featureGroup中循环(
.eachLayer
),并通过检查
.getLatLng()
的结果,使用匹配的坐标识别标记。