道路内的 Mapbox 线串
我有一组从卡车上取出的GPS坐标,我需要在地图上放上MAPBOX的地图,然后画一条线以显示卡车路线。
有没有办法绘制沿着道路的线路?目前,我只是坐标之间的一条直线。
const geojson = data on JSFiddle
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v11',
center: [13.23065662, 43.2500267],
zoom: 12
});
map.on('load', () => {
map.addSource('LineString', {
'type': 'geojson',
'data': geojson
});
map.addLayer({
'id': 'LineString',
'type': 'line',
'source': 'LineString',
'layout': {
'line-join': 'round',
'line-cap': 'round'
},
'paint': {
'line-color': '#BF93E4',
'line-width': 5
}
});
})
I have a set of GPS coordinates taken from a truck, that I need to put on a map with mapbox and then draw a line to show the truck route.
Is there a way to draw the line that follow the roads? At the moment is very I have just a straight line beetween the coordinates.
Since I have a lot of coordinates I put my code here: JSFiddle
const geojson = data on JSFiddle
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v11',
center: [13.23065662, 43.2500267],
zoom: 12
});
map.on('load', () => {
map.addSource('LineString', {
'type': 'geojson',
'data': geojson
});
map.addLayer({
'id': 'LineString',
'type': 'line',
'source': 'LineString',
'layout': {
'line-join': 'round',
'line-cap': 'round'
},
'paint': {
'line-color': '#BF93E4',
'line-width': 5
}
});
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在寻找地图匹配 API。
You're looking for the Map Matching API.