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'>

                            主站蜘蛛池模板: 广州各区危化证办理_危险化学品经营许可证代办 | 东莞工厂厂房装修_无尘车间施工_钢结构工程安装-广东集景建筑装饰设计工程有限公司 | 镀锌钢格栅_热镀锌格栅板_钢格栅板_热镀锌钢格板-安平县昊泽丝网制品有限公司 | 香蕉筛|直线|等厚|弧形|振动筛|香蕉筛厂家-洛阳隆中重工 | 稳尚教育加盟-打造高考志愿填报平台_新高考志愿填报加盟_学业生涯规划加盟 | 石家庄小程序开发_小程序开发公司_APP开发_网站制作-石家庄乘航网络科技有限公司 | 冷却塔改造厂家_不锈钢冷却塔_玻璃钢冷却塔改造维修-广东特菱节能空调设备有限公司 | 新疆系统集成_新疆系统集成公司_系统集成项目-新疆利成科技 | 宽带办理,电信宽带,移动宽带,联通宽带,电信宽带办理,移动宽带办理,联通宽带办理 | 盛源真空泵|空压机-浙江盛源空压机制造有限公司-【盛源官网】 | 工业机械三维动画制作 环保设备原理三维演示动画 自动化装配产线三维动画制作公司-南京燃动数字 聚合氯化铝_喷雾聚氯化铝_聚合氯化铝铁厂家_郑州亿升化工有限公司 | 滑石粉,滑石粉厂家,超细滑石粉-莱州圣凯滑石有限公司 | 浙江华锤电器有限公司_地磅称重设备_防作弊地磅_浙江地磅售后维修_无人值守扫码过磅系统_浙江源头地磅厂家_浙江工厂直营地磅 | 山东商品混凝土搅拌楼-环保型搅拌站-拌合站-分体仓-搅拌机厂家-天宇 | 罗茨真空机组,立式无油往复真空泵,2BV水环真空泵-力侨真空科技 | 丁基胶边来料加工,医用活塞边角料加工,异戊二烯橡胶边来料加工-河北盛唐橡胶制品有限公司 | 家用净水器代理批发加盟_净水机招商代理_全屋净水器定制品牌_【劳伦斯官网】 | 水篦子|雨篦子|镀锌格栅雨水篦子|不锈钢排水篦子|地下车库水箅子—安平县云航丝网制品厂 | 陶氏道康宁消泡剂_瓦克消泡剂_蓝星_海明斯德谦_广百进口消泡剂 | 土壤墒情监测站_土壤墒情监测仪_土壤墒情监测系统_管式土壤墒情站-山东风途物联网 | 上海办公室装修公司_办公室设计_直营办公装修-羚志悦装 | 智慧钢琴-电钢琴-便携钢琴-数码钢琴-深圳市特伦斯乐器有限公司 | 海水晶,海水素,海水晶价格-潍坊滨海经济开发区强隆海水晶厂 | 长沙发电机-湖南发电机-柴油发电机供应厂家-长沙明邦智能科技 | 蓝米云-专注于高性价比香港/美国VPS云服务器及海外公益型免费虚拟主机 | 高清视频编码器,4K音视频编解码器,直播编码器,流媒体服务器,深圳海威视讯技术有限公司 | 淬火设备-钎焊机-熔炼炉-中频炉-锻造炉-感应加热电源-退火机-热处理设备-优造节能 | 化妆品加工厂-化妆品加工-化妆品代加工-面膜加工-广东欧泉生化科技有限公司 | 水厂自动化|污水处理中控系统|水利信息化|智慧水务|智慧农业-山东德艾自动化科技有限公司 | 电脑知识|软件|系统|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网 | 时代北利离心机,实验室离心机,医用离心机,低速离心机DT5-2,美国SKC采样泵-上海京工实业有限公司 工业电炉,台车式电炉_厂家-淄博申华工业电炉有限公司 | 卡诺亚轻高定官网_卧室系统_整家定制_定制家居_高端定制_全屋定制加盟_定制家具加盟_定制衣柜加盟 | 冷凝水循环试验箱-冷凝水试验箱-可编程高低温试验箱厂家-上海巨为(www.juweigroup.com) | 专业生产动态配料系统_饲料配料系统_化肥配料系统等配料系统-郑州鑫晟重工机械有限公司 | 天一线缆邯郸有限公司_煤矿用电缆厂家_矿用光缆厂家_矿用控制电缆_矿用通信电缆-天一线缆邯郸有限公司 | 锂电池砂磨机|石墨烯砂磨机|碳纳米管砂磨机-常州市奥能达机械设备有限公司 | 山东钢格板|栅格板生产厂家供应商-日照森亿钢格板有限公司 | 众品地板网-地板品牌招商_地板装修设计_地板门户的首选网络媒体。 | 齿轮减速机_齿轮减速电机-VEMT蜗轮蜗杆减速机马达生产厂家瓦玛特传动瑞环机电 | 京港视通报道-质量走进大江南北-京港视通传媒[北京]有限公司 | 手板-手板模型-手板厂-手板加工-生产厂家,[东莞创域模型] |