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

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

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

  • <tfoot id='LSruU'></tfoot>
    • <bdo id='LSruU'></bdo><ul id='LSruU'></ul>

        使折線捕捉到傳單中的道路

        Making polyline snap to roads in leaflet(使折線捕捉到傳單中的道路)

            <i id='V6Gda'><tr id='V6Gda'><dt id='V6Gda'><q id='V6Gda'><span id='V6Gda'><b id='V6Gda'><form id='V6Gda'><ins id='V6Gda'></ins><ul id='V6Gda'></ul><sub id='V6Gda'></sub></form><legend id='V6Gda'></legend><bdo id='V6Gda'><pre id='V6Gda'><center id='V6Gda'></center></pre></bdo></b><th id='V6Gda'></th></span></q></dt></tr></i><div class="8vfhhiv" id='V6Gda'><tfoot id='V6Gda'></tfoot><dl id='V6Gda'><fieldset id='V6Gda'></fieldset></dl></div>
              • <small id='V6Gda'></small><noframes id='V6Gda'>

                  <tbody id='V6Gda'></tbody>
                <legend id='V6Gda'><style id='V6Gda'><dir id='V6Gda'><q id='V6Gda'></q></dir></style></legend>
                <tfoot id='V6Gda'></tfoot>
                  <bdo id='V6Gda'></bdo><ul id='V6Gda'></ul>

                  本文介紹了使折線捕捉到傳單中的道路的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在從數據庫中加載標記,然后在標記之間繪制一條折線.我正在使用折線來計算總距離,而不必計算從標記-a 到標記-b 到標記-c 的距離等等.

                  I am loading markers from a database and then drawing a polyline between markers. I am using the polyline to calculate overall distance instead of having to calculate the distance from marker-a to marker-b to marker-c and so on.

                  然而,我的距離并不準確,因為如果兩個標記在彎曲的道路周圍,多段線只是將它們連接起來,而不是沿著道路繪制.

                  My distance is however inaccurate because if two markers are around a curved road, the polyline just connects them instead of drawing it along the road.

                  我知道這在 Google Maps API 中是可能的,但使用限制不適合我,這就是我決定使用傳單的原因.

                  I know this is possible in Google Maps API but the usage restrictions would not suit me which is why I decided to use leaflet.

                  我的標記相距不遠,因為我的 GPS 設備每 10 秒發送一次位置.

                  My markers are not so far apart, because my GPS device sends location every 10 seconds.

                  我找到了 leaflet-routing-machine 插件,我想知道我是否可以使用它使我的折線捕捉到道路嗎?

                  I found the leaflet-routing-machine plugin and I was wondering if I can use this to make my polyline snap to the road?

                  這就是我向地圖添加標記的方式:

                  This is how I am adding markers to my map:

                  function getlocationsfromdb(){
                        group.clearLayers();
                        latlngArray.length=0;
                        var deviceid = $("#selectid").val();
                  
                          $.ajax({
                              type: "POST",
                              url: "functionhandlers/getlocations.php",
                              data: {deviceid:deviceid,start:start,end:end},
                              dataType: 'json',
                              cache: false,
                          })
                          .success(function(response) {   
                              $('input').removeClass('error').next('.errormessage').html('');
                              if(!response.errors && response.result) {
                  
                                  $.each(response.result, function( index, value) {
                                      var latlng = L.latLng(value[7], value[8]);
                                      var marker = L.circleMarker(latlng,{radius:2}).addTo(group);    
                                      latlngArray.push(latlng);   
                  
                                 });
                                    var polyline = L.polyline(latlngArray, {color: '#605ca8'}).addTo(group);  
                                    map.fitBounds(group.getBounds());
                                    var distancetravelled=polyline.measuredDistance();
                                    $("#distancetravelled").html(distancetravelled);
                  
                  
                              } else {
                                  $.each(response.errors, function( index, value) {
                                      // add error classes
                                      $('input[name*='+index+']').addClass('error').after('<div class="errormessage">'+value+'</div>')
                                  });
                              }
                          }); 
                  }
                  

                  有人可以指點我正確的方向嗎?

                  Can someone please point me in the right direction?

                  推薦答案

                  這可以通過leaflet-routing-machine 輕松完成.您可以在初始化路由控件時將 waypoints 設置為 latlngArray:

                  This can be done rather easily with leaflet-routing-machine. You can just set the waypoints to your latlngArray when you initialize the routing control:

                  var control = L.Routing.control({
                    waypoints: latlngArray,
                    show: false,
                    waypointMode: 'snap',
                    createMarker: function() {}
                  }).addTo(map);
                  

                  這里,show: false 使控件不顯示在地圖上,并且空的 createMarker 函數會覆蓋路由機器創建的默認標記,而不是什么都不做(盡管當我們移除控件時,標記將被移除,這只是為了防止它們在找到路線時在屏幕上閃爍).

                  Here, show: false keeps the control from displaying on the map, and the empty createMarker function overrides the default markers that routing machine creates, instead doing nothing (though the markers would be removed when we remove the control, this just keeps them from flashing on the screen when a route is found).

                  你可以通過監聽routeselected事件來提取路由機結果的所有頂點,該事件會返回一個IRoute 對象,其中包含路線的所有方向和幾何形狀.將 .route.coordinates 放置在一個新的 L.polyline 對象中將保留路由,因此我們可以擺脫路由控制:

                  You can extract all the vertices of the routing machine results by listening for the routeselected event, which will return an IRoute object that contains all the directions and geometries for the route. Placing the .route.coordinates in a new L.polyline object will keep the route around, so we can then just get rid of the routing control:

                  control.on('routeselected', function(e) {
                    L.polyline(e.route.coordinates).addTo(group);
                    map.removeControl(control);
                  });
                  

                  在您填充 latlngArray 之后,將上述代碼塊放在您的 .success 回調函數中應該會給您想要的路線.這是一個在工作中展示這個的小提琴:

                  Placing the above code blocks within your .success callback function right after you populates your latlngArray should give you the route you want. Here's a fiddle showing this at work:

                  http://fiddle.jshell.net/nathansnider/ygktexbj/

                  另外,如果您沒有將路由控件用于其他任何事情,并且不想讓它完全顯示(在計算路由時可能仍會出現一個小的白色控件框),您可以簡單地將其隱藏在 CSS:

                  Also, if you're not using the routing control for anything else and want to keep it from showing up entirely (a small white control box may still appear while the route is being calculated), you can simply hide it in CSS:

                  .leaflet-routing-container {
                    display:none;
                  }
                  

                  這篇關于使折線捕捉到傳單中的道路的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 圖層控件添加到側邊欄)
                    <tbody id='v0xuw'></tbody>

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

                      • <small id='v0xuw'></small><noframes id='v0xuw'>

                            主站蜘蛛池模板: 焊接减速机箱体,减速机箱体加工-淄博博山泽坤机械厂 | 渗透仪-直剪仪-三轴仪|苏州昱创百科 | 美的商用净水器_美的直饮机_一级代理经销商_Midea租赁价格-厂家反渗透滤芯-直饮水批发品牌售后 | 香蕉筛|直线|等厚|弧形|振动筛|香蕉筛厂家-洛阳隆中重工 | pbootcms网站模板|织梦模板|网站源码|jquery建站特效-html5模板网 | 【中联邦】增稠剂_增稠粉_水性增稠剂_涂料增稠剂_工业增稠剂生产厂家 | 电子元器件呆滞料_元器件临期库存清仓尾料_尾料优选现货采购处理交易商城 | 液压压力机,液压折弯机,液压剪板机,模锻液压机-鲁南新力机床有限公司 | 免费B2B信息推广发布平台 - 推发网 | 横河变送器-横河压力变送器-EJA变送器-EJA压力变送器-「泉蕴仪表」 | 蓝莓施肥机,智能施肥机,自动施肥机,水肥一体化项目,水肥一体机厂家,小型施肥机,圣大节水,滴灌施工方案,山东圣大节水科技有限公司官网17864474793 | 雷达液位计_超声波风速风向仪_雨量传感器_辐射传感器-山东风途物联网 | 成都思迪机电技术研究所-四川成都思迪编码器 | 防火窗_耐火窗_防火门厂家_防火卷帘门-重庆三乐门业有限公司 | 金属回收_废铜废铁回收_边角料回收_废不锈钢回收_废旧电缆线回收-广东益夫金属回收公司 | 奥运星-汽车性能网评-提供个性化汽车资讯 | 工业废水处理|污水处理厂|废水治理设备工程技术公司-苏州瑞美迪 今日娱乐圈——影视剧集_八卦娱乐_明星八卦_最新娱乐八卦新闻 | 艺术涂料|木纹漆施工|稻草漆厂家|马来漆|石桦奴|水泥漆|选加河南天工涂料 | 空气能采暖,热泵烘干机,空气源热水机组|设备|厂家,东莞高温热泵_正旭新能源 | 座椅式升降机_无障碍升降平台_残疾人升降平台-南京明顺机械设备有限公司 | 齿轮减速机电机一体机_齿轮减速箱加电机一体化-德国BOSERL蜗轮蜗杆减速机电机生产厂家 | 购买舔盐、舔砖、矿物质盐压块机,鱼饵、鱼饲料压块机--请到杜甫机械 | 山西3A认证|太原AAA信用认证|投标AAA信用证书-山西AAA企业信用评级网 | 德州网站制作 - 网站建设设计 - seo排名优化 -「两山建站」 | 菲希尔X射线测厚仪-菲希尔库伦法测厚仪-无锡骏展仪器有限责任公司 | 新疆十佳旅行社_新疆旅游报价_新疆自驾跟团游-新疆中西部国际旅行社 | 吉祥新世纪铝塑板_生产铝塑板厂家_铝塑板生产厂家_临沂市兴达铝塑装饰材料有限公司 | 钢绞线万能材料试验机-全自动恒应力两用机-混凝土恒应力压力试验机-北京科达京威科技发展有限公司 | 奇酷教育-Python培训|UI培训|WEB大前端培训|Unity3D培训|HTML5培训|人工智能培训|JAVA开发的教育品牌 | wika威卡压力表-wika压力变送器-德国wika代理-威卡总代-北京博朗宁科技 | 集菌仪厂家_全封闭_封闭式_智能智能集菌仪厂家-上海郓曹 | 鹤壁创新仪器公司-全自动量热仪,定硫仪,煤炭测硫仪,灰熔点测定仪,快速自动测氢仪,工业分析仪,煤质化验仪器 | 沥青灌缝机_路面灌缝机_道路灌缝机_沥青灌缝机厂家_济宁萨奥机械有限公司 | NBA直播_NBA直播免费观看直播在线_NBA直播免费高清无插件在线观看-24直播网 | 影视模板素材_原创专业影视实拍视频素材-8k像素素材网 | 道康宁消泡剂-瓦克-大川进口消泡剂供应商 | 塑料检查井_双扣聚氯乙烯增强管_双壁波纹管-河南中盈塑料制品有限公司 | 钢骨架轻型板_膨石轻型板_钢骨架轻型板价格_恒道新材料 | 电动卫生级调节阀,电动防爆球阀,电动软密封蝶阀,气动高压球阀,气动对夹蝶阀,气动V型调节球阀-上海川沪阀门有限公司 | 国际船舶网 - 船厂、船舶、造船、船舶设备、航运及海洋工程等相关行业综合信息平台 | 成都亚克力制品,PVC板,双色板雕刻加工,亚克力门牌,亚克力标牌,水晶字雕刻制作-零贰捌广告 |