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="jxzxfh7" 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="nv7dtxj" 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="fbddtxn" id='0KXJq'><tfoot id='0KXJq'></tfoot><dl id='0KXJq'><fieldset id='0KXJq'></fieldset></dl></div>
                            主站蜘蛛池模板: 塑胶跑道_学校塑胶跑道_塑胶球场_运动场材料厂家_中国塑胶跑道十大生产厂家_混合型塑胶跑道_透气型塑胶跑道-广东绿晨体育设施有限公司 | 欧洲MV日韩MV国产_人妻无码一区二区三区免费_少妇被 到高潮喷出白浆av_精品少妇自慰到喷水AV网站 | 消泡剂-水处理消泡剂-涂料消泡剂-切削液消泡剂价格-东莞德丰消泡剂厂家 | 污水/卧式/潜水/钻井/矿用/大型/小型/泥浆泵,价格,参数,型号,厂家 - 安平县鼎千泵业制造厂 | 滑石粉,滑石粉厂家,超细滑石粉-莱州圣凯滑石有限公司 | 时代北利离心机,实验室离心机,医用离心机,低速离心机DT5-2,美国SKC采样泵-上海京工实业有限公司 工业电炉,台车式电炉_厂家-淄博申华工业电炉有限公司 | 磁力抛光机_磁力研磨机_磁力去毛刺机-冠古设备厂家|维修|租赁【官网】 | 伺服电机维修、驱动器维修「安川|三菱|松下」伺服维修公司-深圳华创益 | 医学动画公司-制作3d医学动画视频-医疗医学演示动画制作-医学三维动画制作公司 | HV全空气系统_杭州暖通公司—杭州斯培尔冷暖设备有限公司 | 防弹玻璃厂家_防爆炸玻璃_电磁屏蔽玻璃-四川大硅特玻科技有限公司 | pbootcms网站模板|织梦模板|网站源码|jquery建站特效-html5模板网 | 档案密集架,移动密集架,手摇式密集架,吉林档案密集架-厂家直销★价格公道★质量保证 | 手术室净化装修-手术室净化工程公司-华锐手术室净化厂家 | 铁盒_铁罐_马口铁盒_马口铁罐_铁盒生产厂家-广州博新制罐 | 杭州可当科技有限公司—流量卡_随身WiFi_AI摄像头一站式解决方案 | 水冷式工业冷水机组_风冷式工业冷水机_水冷螺杆冷冻机组-深圳市普威机械设备有限公司 | 线材成型机,线材折弯机,线材成型机厂家,贝朗自动化设备有限公司1 | 聚丙烯酰胺_阴离子_阳离子「用量少」巩义亿腾厂家直销,售后无忧 聚合甘油__盐城市飞龙油脂有限公司 | 管家婆-管家婆软件-管家婆辉煌-管家婆进销存-管家婆工贸ERP | 南京技嘉环保科技有限公司-杀菌除臭剂|污水|垃圾|厕所|橡胶厂|化工厂|铸造厂除臭剂 | 儋州在线-儋州招聘找工作、找房子、找对象,儋州综合生活信息门户! | 设计圈 - 让设计更有价值!| 网站建设,北京网站建设,北京网站建设公司,网站系统开发,北京网站制作公司,响应式网站,做网站公司,海淀做网站,朝阳做网站,昌平做网站,建站公司 | 钢化玻璃膜|手机钢化膜|钢化膜厂家|手机保护膜-【东莞市大象电子科技有限公司】 | 袋式过滤器,自清洗过滤器,保安过滤器,篮式过滤器,气体过滤器,全自动过滤器,反冲洗过滤器,管道过滤器,无锡驰业环保科技有限公司 | 灰板纸、灰底白、硬纸板等纸品生产商-金泊纸业 | 阿里巴巴诚信通温州、台州、宁波、嘉兴授权渠道商-浙江联欣科技提供阿里会员办理 | 菏泽知彼网络科技有限公司| 精密模具-双色注塑模具加工-深圳铭洋宇通 | 电磁铁_推拉电磁铁_机械手电磁吸盘电磁铁厂家-广州思德隆电子公司 | 无机纤维喷涂棉-喷涂棉施工工程-山东华泉建筑工程有限公司▲ | 电磁流量计厂家_涡街流量计厂家_热式气体流量计-青天伟业仪器仪表有限公司 | 播音主持培训-中影人教育播音主持学苑「官网」-中国艺考界的贵族学校 | 低合金板|安阳低合金板|河南低合金板|高强度板|桥梁板_安阳润兴 北京租车牌|京牌指标租赁|小客车指标出租 | 钢骨架轻型板_膨石轻型板_钢骨架轻型板价格_恒道新材料 | 深圳善跑体育产业集团有限公司_塑胶跑道_人造草坪_运动木地板 | 【法利莱住人集装箱厂家】—活动集装箱房,集装箱租赁_大品牌,更放心 | 法钢特种钢材(上海)有限公司 - 耐磨钢板、高强度钢板销售加工 阀门智能定位器_电液动执行器_气动执行机构-赫尔法流体技术(北京)有限公司 | 根系分析仪,大米外观品质检测仪,考种仪,藻类鉴定计数仪,叶面积仪,菌落计数仪,抑菌圈测量仪,抗生素效价测定仪,植物表型仪,冠层分析仪-杭州万深检测仪器网 | 舞台木地板厂家_体育运动木地板_室内篮球馆木地板_实木运动地板厂家_欧氏篮球地板推荐 |