Prevent duplication of two polylines

I am making a Google Maps application that displays GPX tracks. Some tracks overlap a distance. They do not have the same points, but the polylines seem the same when they are drawn. This makes one of them disappear after another. The solution would be to draw overlapping paths next to each other, as subway maps do. How can I do this in the easiest way?

+5
source share
1 answer

Automatically drawing side by side polylines will be very difficult. The math is complicated even if you do it for a fixed zoom level. Lines must be recalculated and redrawn for each zoom level, because lat / lng offsets are needed to offset lines with the same pixel width for each zoom level.

If you have only a few tracks, try displaying them in contrasting colors with different widths, first showing wider ones. Thus, you can see the sides of a wider track as a narrower track stretches above it.

+3
source

All Articles