pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <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="gc0bs50" id='qn6V6'><tfoot id='qn6V6'></tfoot><dl id='qn6V6'><fieldset id='qn6V6'></fieldset></dl></div>
      3. 如何計算像geojson.io這樣的Leaflet中折線的距離?

        How to calculate the distance of a polyline in Leaflet like geojson.io?(如何計算像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="t3xakfl" 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>
                  本文介紹了如何計算像geojson.io這樣的Leaflet中折線的距離?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

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

                  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.

                  我已經算出了多邊形區域的特征,但我不知道如何計算折線的距離.

                  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 本身是否有一種方法可以幫助我計算折線的距離?geogson.io 的開發人員也有一種計算距離的方法,但我似乎無法通過查看他們的代碼來弄清楚.我不是經驗豐富的 Javascript 開發人員.歡迎任何幫助.:)

                  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. :)

                  推薦答案

                  所以我終于自己想出了一個算法.我基本上找到了包含折線的所有 latlngs 的折線的屬性,然后我讓它通過一個循環,我使用 Leaflet 中的 distanceTo 方法來計算距離點之間并不斷將它們添加到 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();
                  }
                  

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

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

                  相關文檔推薦

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

                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="pte3luw" id='0KXJq'><tfoot id='0KXJq'></tfoot><dl id='0KXJq'><fieldset id='0KXJq'></fieldset></dl></div>
                            主站蜘蛛池模板: 上海刑事律师|刑事辩护律师|专业刑事犯罪辩护律师免费咨询-[尤辰荣]金牌上海刑事律师团队 | 北京发电车出租-发电机租赁公司-柴油发电机厂家 - 北京明旺盛安机电设备有限公司 | 上海新光明泵业制造有限公司-电动隔膜泵,气动隔膜泵,卧式|立式离心泵厂家 | 北京律师事务所_房屋拆迁律师_24小时免费法律咨询_云合专业律师网 | 北京西风东韵品牌与包装设计公司,创造视觉销售力! | 东莞市天进机械有限公司-钉箱机-粘箱机-糊箱机-打钉机认准东莞天进机械-厂家直供更放心! | ph计,实验室ph计,台式ph计,实验室酸度计,台式酸度计 | 保温杯,儿童婴童奶瓶,运动水壶「广告礼品杯定制厂家」超朗保温杯壶 | 内窥镜-工业内窥镜厂家【上海修远仪器仪表有限公司】 | 耐酸泵,耐酸泵厂家-淄博华舜耐腐蚀真空泵| 砂石生产线_石料生产线设备_制砂生产线设备价格_生产厂家-河南中誉鼎力智能装备有限公司 | 国产离子色谱仪,红外分光测油仪,自动烟尘烟气测试仪-青岛埃仑通用科技有限公司 | 齿轮减速机电机一体机_齿轮减速箱加电机一体化-德国BOSERL蜗轮蜗杆减速机电机生产厂家 | 步进电机_agv电机_伺服马达-伺服轮毂电机-和利时电机 | 板式换网器_柱式换网器_自动换网器-郑州海科熔体泵有限公司 | 全自动过滤器_反冲洗过滤器_自清洗过滤器_量子除垢环_量子环除垢_量子除垢 - 安士睿(北京)过滤设备有限公司 | 精准猎取科技资讯,高效阅读科技新闻_科技猎 | 标准件-非标紧固件-不锈钢螺栓-非标不锈钢螺丝-非标螺母厂家-三角牙锁紧自攻-南京宝宇标准件有限公司 | 渣土车电机,太阳能跟踪器电机,蜗轮蜗杆减速电机厂家-淄博传强电机 | 安规_综合测试仪,电器安全性能综合测试仪,低压母线槽安规综合测试仪-青岛合众电子有限公司 | 河北凯普威医疗器材有限公司,高档轮椅系列,推车系列,座厕椅系列,协步椅系列,拐扙系列,卫浴系列 | 淘气堡_室内儿童乐园_户外无动力儿童游乐设备-高乐迪(北京) | 手机存放柜,超市储物柜,电子储物柜,自动寄存柜,行李寄存柜,自动存包柜,条码存包柜-上海天琪实业有限公司 | 喷漆房_废气处理设备-湖北天地鑫环保设备有限公司 | 深圳展厅设计_企业展馆设计_展厅设计公司_数字展厅设计_深圳百艺堂 | 电气控制系统集成商-PLC控制柜变频控制柜-非标自动化定制-电气控制柜成套-NIDEC CT变频器-威肯自动化控制 | 黑龙江京科脑康医院-哈尔滨精神病医院哪家好_哈尔滨精神科医院排名_黑龙江精神心理病专科医院 | 媒介云-全网整合营销_成都新闻媒体发稿_软文发布平台 | 挤出机_橡胶挤出机_塑料挤出机_胶片冷却机-河北伟源橡塑设备有限公司 | 耐酸碱泵-自吸耐酸碱泵型号「品牌厂家」立式耐酸碱泵价格-昆山国宝过滤机有限公司首页 | 防弹玻璃厂家_防爆炸玻璃_电磁屏蔽玻璃-四川大硅特玻科技有限公司 | 安全,主动,被动,柔性,山体滑坡,sns,钢丝绳,边坡,防护网,护栏网,围栏,栏杆,栅栏,厂家 - 护栏网防护网生产厂家 | 万博士范文网-您身边的范文参考网站Vanbs.com | 丝杆升降机-不锈钢丝杆升降机-非标定制丝杆升降机厂家-山东鑫光减速机有限公司 | 塑料撕碎机_编织袋撕碎机_废纸撕碎机_生活垃圾撕碎机_废铁破碎机_河南鑫世昌机械制造有限公司 | 保镖公司-私人保镖-深圳保镖公司【环宇兄弟保镖】 | 最新电影-好看的电视剧大全-朝夕电影网 | sus630/303cu不锈钢棒,440C/430F/17-4ph不锈钢研磨棒-江苏德镍金属科技有限公司 | 不干胶标签-不干胶贴纸-不干胶标签定制-不干胶标签印刷厂-弗雷曼纸业(苏州)有限公司 | 大鼠骨髓内皮祖细胞-小鼠神经元-无锡欣润生物科技有限公司 | 氮化镓芯片-碳化硅二极管 - 华燊泰半导体 |