从传单例程机器将geojson数据加载到turfjs中

时间:2019-02-15 09:42:58

标签: javascript leaflet osrm turfjs

我正在尝试使用turfjs和传单路由机器。

我想加载一条路线,然后使用带有buffer选项的turfjs将其添加到地图中。因此,我希望能够穿越这条路线,并且在50米内的任何地方显示常规机器提供的道路名称。

我可以这样得到路线:

function getroute() {
myroutewithout = L.Routing.control({
  waypoints: [
    L.latLng(window.my_lat, window.my_lng),
    L.latLng(window.job_p_lat, window.job_p_lng)
  ],show: true, units: 'imperial',
 router: L.Routing.mapbox('KEY-HERE'),
  createMarker: function(i, wp, nWps) {
    if (i === 0 || i === nWps + 1) {
      // here change the starting and ending icons
      return mymarker = L.marker(wp.latLng, {
        icon: window.operatorIcon
      });
    } else {
      // here change all the others
      return job_start = L.marker(wp.latLng, {
        icon: window.jobIcon
      }); 
    }
  }
}).addTo(map);

但是不确定如何获取数据并使用turfjs将其添加到添加项中。我找到了这两个教程,我认为这是我需要的基础?

这是保存和使用geojson数据的方式:

https://github.com/perliedman/leaflet-routing-machine/issues/17#issuecomment-198270151

这就是我要使用的方式,只显示道路名称。

https://bl.ocks.org/morganherlocker/597e16852d95acafe5dc

有人对我应该从哪里开始有任何想法,因为我对此非常迷茫。

谢谢

0 个答案:

没有答案