如何在leaflet.js上绘制不同颜色的路径叠加?

How to draw path superposition with different color on leaflet.js?

我想在 leaflet.js 地图上从相同的坐标绘制多条路径。我考虑过使用三角函数计算在路径之间形成间隙,但是处理缩放级别、将 GPS 坐标转换为矢量等太复杂了。

我现在的图是这样的(绿色路径下还有一条路径):

我想要这样的东西:

当然,坐标、角度和缩放级别可以改变。

您可能会对 Leaflet Polyline Offset 插件感兴趣:

This plugin adds to Leaflet Polylines the ability to be drawn with a relative pixel offset, without modifying their actual LatLngs. The offset value can be either negative or positive, for left- or right-side offset, and remains constant across zoom levels.

Bus lines demo