Mapbox中路线的多色折线 [英] Multicolor polylines for a route in mapbox
问题描述
我用我的应用程序记录了路线,主要是摩托车,并且想根据路线各点的速度为其着色.
i record routes with my app, mostly for motorbikes, and want to color it depending on the speed at each point of the route.
基本上我知道如何在mapbox中做到这一点,这就是问题所在.由于您只能为一条折线设置颜色,因此我必须将路线分成多个速度段,并使用其特定的颜色打印每个路线段的折线,这基本上可以正常工作.问题是我最多有500-2000条折线用于一条路线.因此地图很容易崩溃.
basically i know how to do it in mapbox and that is the problem. since you can set a color for only one polyline, i have to split up the route in speed sections and print every route sections polyline with it's specific color, which works fine basically. problem is that i have up to 500-2000 polylines for a route. so the map crashes very easily.
当我在地图上设置5000个图像批注时,我没有这个问题,我可以单独为其着色.这可能是一个解决方案,但最多可能需要20秒钟才能打印所有图像注释.还有其他选项可以使彩色路线像图像中的on一样吗?
i don't have that problem when i set like 5000 image annotations to the map, which i can color individually. this could be a solution but it can take up to 20 seconds to print all image annotations. any other options to make a colored route like the on in the image ?
推荐答案
使用开箱即用的地图框折线是不可能的.
This is not possible with out of the box mapbox polylines.
您将不得不添加一个新层,执行平移并添加渐变线.这可能使您开始画线: https://stackoverflow.com/a/25034854/4019540
You will have to add a new layer, perform the translations and add the gradient lines yourself. This might get you started drawing the lines: https://stackoverflow.com/a/25034854/4019540
祝你好运
这篇关于Mapbox中路线的多色折线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!