• <legend id='d8BBu'><style id='d8BBu'><dir id='d8BBu'><q id='d8BBu'></q></dir></style></legend><tfoot id='d8BBu'></tfoot>

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

        • <bdo id='d8BBu'></bdo><ul id='d8BBu'></ul>

      1. <i id='d8BBu'><tr id='d8BBu'><dt id='d8BBu'><q id='d8BBu'><span id='d8BBu'><b id='d8BBu'><form id='d8BBu'><ins id='d8BBu'></ins><ul id='d8BBu'></ul><sub id='d8BBu'></sub></form><legend id='d8BBu'></legend><bdo id='d8BBu'><pre id='d8BBu'><center id='d8BBu'></center></pre></bdo></b><th id='d8BBu'></th></span></q></dt></tr></i><div id='d8BBu'><tfoot id='d8BBu'></tfoot><dl id='d8BBu'><fieldset id='d8BBu'></fieldset></dl></div>
      2. 如何将两个 geoJSON 特征集合添加到两个图层组中

        时间:2023-08-09

              • <bdo id='7mLci'></bdo><ul id='7mLci'></ul>

              • <tfoot id='7mLci'></tfoot>

                <legend id='7mLci'><style id='7mLci'><dir id='7mLci'><q id='7mLci'></q></dir></style></legend>

                  <tbody id='7mLci'></tbody>

                  <small id='7mLci'></small><noframes id='7mLci'>

                  <i id='7mLci'><tr id='7mLci'><dt id='7mLci'><q id='7mLci'><span id='7mLci'><b id='7mLci'><form id='7mLci'><ins id='7mLci'></ins><ul id='7mLci'></ul><sub id='7mLci'></sub></form><legend id='7mLci'></legend><bdo id='7mLci'><pre id='7mLci'><center id='7mLci'></center></pre></bdo></b><th id='7mLci'></th></span></q></dt></tr></i><div id='7mLci'><tfoot id='7mLci'></tfoot><dl id='7mLci'><fieldset id='7mLci'></fieldset></dl></div>
                  本文介绍了如何将两个 geoJSON 特征集合添加到两个图层组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有两个 geoJSON 功能集合需要添加到地图中,我还希望通过图层可见性控制器打开和关闭它们,如 http://leafletjs.com/examples/layers-control.html

                  I have two geoJSON feature collections that I need to add to the map, and I also want them to be toggled on and off via the layer visibility controllers as shown in http://leafletjs.com/examples/layers-control.html

                  我该怎么做?

                  推荐答案

                  Leaflet的GeoJSON层L.GeoJSON的使用也有一个很好的教程,可以在这里找到:http://leafletjs.com/examples/geojson.html 这里是 的参考L.GeoJSON:http://leafletjs.com/reference.html#geojson您已经在 L.control.layers 上找到了教程,这里是它的参考:http://leafletjs.com/reference.html#control-layers

                  There is also a very good tutorial on the usage of L.GeoJSON, Leaflet's GeoJSON layer, which can be found here: http://leafletjs.com/examples/geojson.html and here is the reference for L.GeoJSON: http://leafletjs.com/reference.html#geojson You already found the tutorial on L.control.layers, here is the reference for it: http://leafletjs.com/reference.html#control-layers

                  其实做起来很简单,只需要创建一个layercontrol,使用你喜欢的XHR库加载一个GeoJSON文件到你的脚本中,使用检索到的数据来定义一个L.GeoJSON图层并将其添加到图层控件.在代码中:

                  It's actually quite simple to do, it's just a matter of creating a layercontrol, loading a GeoJSON file into your script by using your favorite XHR library, use the retrieved data to defined a L.GeoJSON layer and add it to the layercontrol. In code:

                  // Create the layercontrol and add it to the map
                  var controlLayers = L.control.layers().addTo(map);
                  
                  // Loading a GeoJSON file (using jQuery's $.getJSON)    
                  $.getJSON('/my-folder/my-file.json', function (data) {
                  
                    // Use the data to create a GeoJSON layer and add it to the map
                    var geojsonLayer = L.geoJson(data).addTo(map);
                  
                    // Add the geojson layer to the layercontrol
                    controlLayers.addOverlay(geojsonLayer, 'My GeoJSON layer title');
                  
                  });
                  

                  关于 Plunker 的工作示例:http://plnkr.co/edit/tFVrrq?p=预览

                  A working example on Plunker: http://plnkr.co/edit/tFVrrq?p=preview

                  这篇关于如何将两个 geoJSON 特征集合添加到两个图层组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:react-leaflet 创建自定义组件 下一篇:Leaflet - 在弹出窗口中获取标记的纬度和经度

                  相关文章

                  最新文章

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

                    1. <tfoot id='qKd67'></tfoot><legend id='qKd67'><style id='qKd67'><dir id='qKd67'><q id='qKd67'></q></dir></style></legend>
                        <bdo id='qKd67'></bdo><ul id='qKd67'></ul>

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