gpt4 book ai didi

javascript - mapbox LineString 跟随道路

转载 作者:行者123 更新时间:2023-11-28 08:02:44 25 4
gpt4 key购买 nike

我有一组 GPS 位置,我用 Mapbox 将其放在 map 上,然后在点之间画一条线。

有没有办法画一条沿着道路的平滑/智能线?而不是我在图纸上得到的?

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Single marker</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox.js/v2.0.0/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.0.0/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id='map'></div>

<script>
L.mapbox.accessToken = '<TOKEN_HERE>';
var map = L.mapbox.map('map', 'examples.map-i86nkdio')
.setView([40.763656, -73.980603], 15);

L.mapbox.featureLayer({
// this feature is in the GeoJSON format: see geojson.org
// for the full specification
type: 'Feature',
geometry: {
type: 'LineString',
// coordinates here are in longitude, latitude order because
// x, y is the standard for GeoJSON and many formats
coordinates: [
[ -73.979552 , 40.766119 ],
[ -73.982556 , 40.761991 ],
[ -73.980399 , 40.759858 ],
[ -73.978575 , 40.756607 ]
]
},
properties: {
title: 'test',
description: 'Test',
}
}).addTo(map);
</script>
</body>
</html>

图片:http://postimg.org/image/x1syq28o5/

最佳答案

您绘制的线条仅包含您提供的四个点。所以基本上,您需要更好的源数据。

您是在一般情况下尝试这样做还是仅针对此示例?您正在绘制的 map 基于 OpenStreetMap,因此如果您可以获取该数据,您就可以在 basemap 之上绘制所需道路的副本。

关于javascript - mapbox LineString 跟随道路,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25199787/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com