<legend id='lVoaT'><style id='lVoaT'><dir id='lVoaT'><q id='lVoaT'></q></dir></style></legend>

      <small id='lVoaT'></small><noframes id='lVoaT'>

        <bdo id='lVoaT'></bdo><ul id='lVoaT'></ul>
        <tfoot id='lVoaT'></tfoot>

        <i id='lVoaT'><tr id='lVoaT'><dt id='lVoaT'><q id='lVoaT'><span id='lVoaT'><b id='lVoaT'><form id='lVoaT'><ins id='lVoaT'></ins><ul id='lVoaT'></ul><sub id='lVoaT'></sub></form><legend id='lVoaT'></legend><bdo id='lVoaT'><pre id='lVoaT'><center id='lVoaT'></center></pre></bdo></b><th id='lVoaT'></th></span></q></dt></tr></i><div id='lVoaT'><tfoot id='lVoaT'></tfoot><dl id='lVoaT'><fieldset id='lVoaT'></fieldset></dl></div>

      1. 在 Leaflet 中获取当前地图范围内的标记/图层列表

        时间:2023-08-09
      2. <i id='LCJxC'><tr id='LCJxC'><dt id='LCJxC'><q id='LCJxC'><span id='LCJxC'><b id='LCJxC'><form id='LCJxC'><ins id='LCJxC'></ins><ul id='LCJxC'></ul><sub id='LCJxC'></sub></form><legend id='LCJxC'></legend><bdo id='LCJxC'><pre id='LCJxC'><center id='LCJxC'></center></pre></bdo></b><th id='LCJxC'></th></span></q></dt></tr></i><div id='LCJxC'><tfoot id='LCJxC'></tfoot><dl id='LCJxC'><fieldset id='LCJxC'></fieldset></dl></div>

                <tbody id='LCJxC'></tbody>

              <legend id='LCJxC'><style id='LCJxC'><dir id='LCJxC'><q id='LCJxC'></q></dir></style></legend>
            • <small id='LCJxC'></small><noframes id='LCJxC'>

                  <bdo id='LCJxC'></bdo><ul id='LCJxC'></ul>
                • <tfoot id='LCJxC'></tfoot>
                  本文介绍了在 Leaflet 中获取当前地图范围内的标记/图层列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这有点类似于这里提出的问题--

                  我正在为地图应用程序编写一个搜索框,该应用程序从服务器一次检索一整套搜索结果(人名和信息),然后翻阅结果列表.因此,在地图上的任何给定点,都有两种标记 - 背景标记用于在搜索结果中但不在当前页面中的点,以及用于在当前搜索结果页面中的点的前景标记.

                  I'm writing a search box for a map application, which retrieves a whole set of search results (people's names & info) at once from a server and then pages through the list of results. So at any given point on the map there are two kinds of markers -- a background marker for points which are in the search results but not in the current page, and a foreground marker for points which are in the current page of search results.

                  所有这一切都很好.我现在想做的是设置它,以便如果用户缩放或平移地图,搜索结果列表会更新以仅显示当前地图范围内的标记.

                  All this works nicely.. what I'd like to do now is set it up so that if a user zooms or pans the map, the search results list updates to show only markers within the current map bounds.

                  显然有服务器端的方法可以做到这一点,或者我也可以遍历整个标记列表,看看哪些符合当前范围;但是有人知道在传单中执行此操作的内置方法吗?看起来像 map.getVisibleLayers() 的东西?

                  Obviously there are server-side ways to do this, or I could also just run through the whole list of markers to see which fit within the current bounds; but does anybody know a built-in way to do this within leaflet? Something which would look like map.getVisibleLayers()?

                  推荐答案

                  我认为这可能会有所帮助:https://github.com/stefanocudini/leaflet-list-markers

                  I think this may be of help: https://github.com/stefanocudini/leaflet-list-markers

                  从演示中可以看出,包括图层中的所有标记,此插件仅显示当前视口中可见的标记列表.它的用法很简单,连续:

                  as you can see from the demo, including all markers in a layer, this plugin shows a list of only those visible in the current viewport. Its usage is simple, in a row:

                  var markersLayer = new L.LayerGroup();
                  map.addControl( new L.Control.ListMarkers({layer: markersLayer}) );
                  

                  获取代码如下:

                  var layers = L.LayerGroup(), //layers contains all markers..
                      contained = [];          //makers in map boundingbox
                  
                  layers.eachLayer(function(l) {
                      if( l instanceof L.Marker && map.getBounds().contains(l.getLatLng()) )
                          contained.push(l);
                  });
                  

                  这篇关于在 Leaflet 中获取当前地图范围内的标记/图层列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Leaflet.js - 点击时设置标记,拖动时更新位置 下一篇:未找到 React-Leaflet 标记文件

                  相关文章

                  最新文章

                • <tfoot id='6iV7V'></tfoot>

                    <bdo id='6iV7V'></bdo><ul id='6iV7V'></ul>
                  <i id='6iV7V'><tr id='6iV7V'><dt id='6iV7V'><q id='6iV7V'><span id='6iV7V'><b id='6iV7V'><form id='6iV7V'><ins id='6iV7V'></ins><ul id='6iV7V'></ul><sub id='6iV7V'></sub></form><legend id='6iV7V'></legend><bdo id='6iV7V'><pre id='6iV7V'><center id='6iV7V'></center></pre></bdo></b><th id='6iV7V'></th></span></q></dt></tr></i><div id='6iV7V'><tfoot id='6iV7V'></tfoot><dl id='6iV7V'><fieldset id='6iV7V'></fieldset></dl></div>
                  <legend id='6iV7V'><style id='6iV7V'><dir id='6iV7V'><q id='6iV7V'></q></dir></style></legend>

                  1. <small id='6iV7V'></small><noframes id='6iV7V'>