gpt4 book ai didi

mapbox-gl-js - 如何在 Mapbox-gl-js 中跟踪虚线(非虚线)路径?

转载 作者:行者123 更新时间:2023-12-04 04:39:44 39 4
gpt4 key购买 nike

我正在使用最新版本的 Mapbox-gl-js,我想以等距圆的形式追踪一条路径,就像谷歌地图在我们询问“步行”路线时所做的那样:

enter image description here

使用 Mapbox-gl-js,我尝试了虚线和圆形布局,但它们不能满足我的需求:

// Dash
map.addLayer({
id: 'my-points',
type: 'line',
source: 'my-data',
paint: {
'line-color': 'gray',
'line-width': 10,
'line-dasharray': [1, 1],
},
});

// Circles
map.addLayer({
id: 'my-lines',
type: 'circle',
source: 'my-data',
paint: {
'circle-color': 'red',
'circle-radius': 3,
},
});


虚线样式尊重等距离但不显示圆圈:

enter image description here

圆圈样式显示圆圈,但仅在提供的坐标处,而不是整个路线。

enter image description here

所以我的问题是:有没有办法沿着 geojson/lineString 路径跟踪等距的点、圆或可定制的模式?

谢谢!

最佳答案

虽然还不是很完美,但您可以使用 line 更接近您想要的效果。图层样式使用line-cap布局 Prop 并将您的线段长度设置为零:

    layout: {
'line-cap': 'round'
},
paint: {
'line-width': 10,
'line-dasharray': [0, 2]
}

enter image description here

关于mapbox-gl-js - 如何在 Mapbox-gl-js 中跟踪虚线(非虚线)路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54688038/

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