Leaflet: how to deal with overlapping lines?

How can I work with overlapping lines in a sheet map library?

problem illustration

I load geoJSON from the sid server and draw directly to the map. If there are two identical entries, Liflet draws them twice. This could be fixed by looking for exact duplication on the server side.

This, however, does not work for different datasets sharing the same spaces. As a result, parts of both are drawn in the same place.

+4
source share
1 answer

It seems that the lines are rendered with the opacity of the default polyline. Litelet 0.5. If you yourself created polylines in your code, you can override the opacity to make the lines opaque as follows:

var myPolyLine = new L.Polyline( myPoints, { opacity: 1 } ); 

The line that will be displayed on top will then be the line that you added to the last map (one or the other will be on top if you do not make them opaque in the same color). But this can be controversial if you upload to geoJSON directly and don't have control over how Leaflet does it.

0
source

Source: https://habr.com/ru/post/1497239/


All Articles