久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

      1. <legend id='qn6V6'><style id='qn6V6'><dir id='qn6V6'><q id='qn6V6'></q></dir></style></legend>

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

        <tfoot id='qn6V6'></tfoot>

      2. <i id='qn6V6'><tr id='qn6V6'><dt id='qn6V6'><q id='qn6V6'><span id='qn6V6'><b id='qn6V6'><form id='qn6V6'><ins id='qn6V6'></ins><ul id='qn6V6'></ul><sub id='qn6V6'></sub></form><legend id='qn6V6'></legend><bdo id='qn6V6'><pre id='qn6V6'><center id='qn6V6'></center></pre></bdo></b><th id='qn6V6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qn6V6'><tfoot id='qn6V6'></tfoot><dl id='qn6V6'><fieldset id='qn6V6'></fieldset></dl></div>
      3. 如何計(jì)算像geojson.io這樣的Leaflet中折線的距離?

        How to calculate the distance of a polyline in Leaflet like geojson.io?(如何計(jì)算像geojson.io這樣的Leaflet中折線的距離?)

            • <bdo id='XqErf'></bdo><ul id='XqErf'></ul>
            • <i id='XqErf'><tr id='XqErf'><dt id='XqErf'><q id='XqErf'><span id='XqErf'><b id='XqErf'><form id='XqErf'><ins id='XqErf'></ins><ul id='XqErf'></ul><sub id='XqErf'></sub></form><legend id='XqErf'></legend><bdo id='XqErf'><pre id='XqErf'><center id='XqErf'></center></pre></bdo></b><th id='XqErf'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XqErf'><tfoot id='XqErf'></tfoot><dl id='XqErf'><fieldset id='XqErf'></fieldset></dl></div>
                <legend id='XqErf'><style id='XqErf'><dir id='XqErf'><q id='XqErf'></q></dir></style></legend>

                    <tbody id='XqErf'></tbody>

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

                  <tfoot id='XqErf'></tfoot>
                  本文介紹了如何計(jì)算像geojson.io這樣的Leaflet中折線的距離?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在使用 Mapbox 和 Leaflet 繪制地圖,我應(yīng)該讓用戶繪制多邊形并計(jì)算并顯示該多邊形的面積,我還需要讓用戶繪制一條折線并顯示折線的距離.

                  I am working on a map with Mapbox and Leaflet and I am supposed to let the user draw polygons and calculate and show the are of that polygon and I also need to let the user draw a polyline and show the distance of the polyline.

                  我已經(jīng)算出了多邊形區(qū)域的特征,但我不知道如何計(jì)算折線的距離.

                  I have figured out the polygon area feature but I cannot figure out how to calculate the distance of a polyline.

                  我的代碼如下:

                  loadScript('https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-draw/v0.2.2/leaflet.draw.js', function(){
                      loadScript('https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-geodesy/v0.1.0/leaflet-geodesy.js', function(){
                          var featureGroup = L.featureGroup().addTo(map);
                  
                          var drawControl = new L.Control.Draw({
                          edit: {
                              featureGroup: featureGroup
                          },
                          draw: {
                              polygon: true,
                              polyline: true,
                              rectangle: false,
                              circle: false,
                              marker: false
                          }
                      }).addTo(map);
                  
                      map.on('draw:created', showPolygonArea);
                      map.on('draw:edited', showPolygonAreaEdited);
                  
                      function showPolygonAreaEdited(e) {
                          e.layers.eachLayer(function(layer) {
                              showPolygonArea({ layer: layer });
                          });
                      }
                      function showPolygonArea(e) {
                          var type = e.layerType,
                          layer = e.layer;
                  
                          if (type === 'polygon') {
                              featureGroup.clearLayers();
                              featureGroup.addLayer(e.layer);
                              e.layer.bindPopup(((LGeo.area(e.layer) / 1000000) * 0.62137).toFixed(2) + ' mi<sup>2</sup>');
                              e.layer.openPopup();
                          }
                  
                          if (type === 'polyline') {
                              featureGroup.clearLayers();
                              featureGroup.addLayer(e.layer);
                              // What do I do different here to calculate the distance of the polyline?
                              // Is there a method in the LGeo lib itself?
                              // e.layer.bindPopup(((LGeo.area(e.layer) / 1000000) * 0.62137).toFixed(2) + ' mi<sup>2</sup>');
                              e.layer.openPopup();
                          }
                  
                      }
                      });
                  });
                  

                  LGeo lib 本身是否有一種方法可以幫助我計(jì)算折線的距離?geogson.io 的開發(fā)人員也有一種計(jì)算距離的方法,但我似乎無法通過查看他們的代碼來弄清楚.我不是經(jīng)驗(yàn)豐富的 Javascript 開發(fā)人員.歡迎任何幫助.:)

                  Is there a method in the LGeo lib itself which will help me calculate the distance of the polyline? The devs at geogson.io also have a way to calculate the distance but I cannot seem to figure it out looking at their code. I am not a seasoned Javascript developer. Any help is welcome. :)

                  推薦答案

                  所以我終于自己想出了一個(gè)算法.我基本上找到了包含折線的所有 latlngs 的折線的屬性,然后我讓它通過一個(gè)循環(huán),我使用 Leaflet 中的 distanceTo 方法來計(jì)算距離點(diǎn)之間并不斷將它們添加到 totalDistance 變量中.

                  So I finally came up with an algorithm myself. I basically found the property of the polyline which holds all the latlngs of the polyline and then I made it go through a loop and I used the distanceTo method from Leaflet to calculate distance between points and kept on adding them to a totalDistance variable.

                  if (type === 'polyline') {
                      featureGroup.clearLayers();
                      featureGroup.addLayer(e.layer);
                  
                      // Calculating the distance of the polyline
                      var tempLatLng = null;
                      var totalDistance = 0.00000;
                      $.each(e.layer._latlngs, function(i, latlng){
                          if(tempLatLng == null){
                              tempLatLng = latlng;
                              return;
                          }
                  
                          totalDistance += tempLatLng.distanceTo(latlng);
                          tempLatLng = latlng;
                      });
                      e.layer.bindPopup((totalDistance).toFixed(2) + ' meters');
                      e.layer.openPopup();
                  }
                  

                  這篇關(guān)于如何計(jì)算像geojson.io這樣的Leaflet中折線的距離?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個(gè)多邊形點(diǎn)是否在傳單中的另一個(gè)內(nèi)部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標(biāo)記群集圖標(biāo)顏色,繼承其余默認(rèn) CSS 屬性)
                  Trigger click on leaflet marker(觸發(fā)點(diǎn)擊傳單標(biāo)記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認(rèn)加載磁貼顏色?)
                  Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側(cè)邊欄)

                1. <legend id='0KXJq'><style id='0KXJq'><dir id='0KXJq'><q id='0KXJq'></q></dir></style></legend>
                    <tbody id='0KXJq'></tbody>

                    <small id='0KXJq'></small><noframes id='0KXJq'>

                    <tfoot id='0KXJq'></tfoot>

                    • <bdo id='0KXJq'></bdo><ul id='0KXJq'></ul>
                            <i id='0KXJq'><tr id='0KXJq'><dt id='0KXJq'><q id='0KXJq'><span id='0KXJq'><b id='0KXJq'><form id='0KXJq'><ins id='0KXJq'></ins><ul id='0KXJq'></ul><sub id='0KXJq'></sub></form><legend id='0KXJq'></legend><bdo id='0KXJq'><pre id='0KXJq'><center id='0KXJq'></center></pre></bdo></b><th id='0KXJq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0KXJq'><tfoot id='0KXJq'></tfoot><dl id='0KXJq'><fieldset id='0KXJq'></fieldset></dl></div>
                            主站蜘蛛池模板: 精品欧美激情在线观看 | 在线国产精品一区 | 欧美久久不卡 | www.久久久.com | 精久久| 亚洲国产精品久久 | 午夜爽爽男女免费观看hd | 午夜精品一区二区三区在线视 | 自拍偷拍精品 | 天天综合国产 | 一区二区三 | 成年人免费网站 | 亚洲91精品| 美女网站视频免费黄 | 国产一级片网站 | 国产一级久久久久 | 亚洲欧洲综合av | 一级毛片色一级 | 日韩在线视频精品 | 岛国毛片在线观看 | 人人九九 | 91在线免费视频 | 欧美一区二区 | 婷婷色国产偷v国产偷v小说 | 伊人影院99 | 亚洲精品久久久蜜桃网站 | 日本欧美国产在线观看 | 亚洲字幕在线观看 | 日韩一级精品视频在线观看 | 国产成人免费视频网站视频社区 | 亚洲高清视频在线观看 | 亚洲成人精品一区 | 婷婷国产一区 | 久久久久免费 | 日本黄色激情视频 | 国产午夜在线 | 色婷婷精品久久二区二区蜜臂av | av永久免费 | 97久久国产 | 自拍第一页 | 日本午夜一区二区三区 |