Leaflet.PolylineOffset icon indicating copy to clipboard operation
Leaflet.PolylineOffset copied to clipboard

Setting an offset creates circles

Open nlafleur opened this issue 3 years ago • 4 comments

PolylineOffset creates circles whenever I set an offset to my polyline.

The polyline I use has some coordinates which are very close to eachother, this is probably the cause.

based on the following data: https://gist.github.com/nlafleur/4092716f612859335dcdeaf990ab5863#file-sectiondata

Single polyline: image

Single polyline + extra polyline added on the same coordinates: image

Extra polyline code:

var red = L.polyline(sectionCoords, {
  color: "red",
  opacity: 1,
  offset: 0
}).addTo(groupRef)

Single polyline + extra polyline added with the same coordinates with an offset of 5: image

Offset polyline code:

var red = L.polyline(sectionCoords, {
  color: "red",
  opacity: 1,
  offset: 5
}).addTo(groupRef)

I tried adding the "smoothFactor" (https://leafletjs.com/reference.html#polyline-smoothfactor) with an high number but this doesn't fix everything + it simplifies the polyline too much.

nlafleur avatar Nov 10 '21 14:11 nlafleur

Am also having this issue.

Looking in to using this library to see if i can simplify the polyline that way.

https://mourner.github.io/simplify-js/

jamieodonnell avatar Apr 06 '22 12:04 jamieodonnell

I am simlilarly seeing this issue with PCT trail data collected with a GPS. It must be related to the point density but it happens without specifying any Polyline style options other than offset. pctapt = L.geoJSON(pct, { // color: 'black', // weight: 2, // opacity: 1, offset: 5 }).addTo(map);

Screen Shot 2022-11-06 at 11 47 32 AM

tsmcgrath avatar Nov 06 '22 19:11 tsmcgrath

Seeing same issue at my end. Red color is what the polyline is supposed to look like. Green : I've applied offset: 50

image

answerquest avatar Feb 15 '24 07:02 answerquest

This forked version (https://github.com/higaa/Leaflet.PolylineOffset) seems to improve a good number of similar issues that I was having. Not perfect - some of the artifacts are still present. However, it does remove all of the circles. image image

tombrennan06 avatar Mar 24 '24 09:03 tombrennan06