Closed southmedia closed 4 years ago
@southmedia It seems like the PolylineOffset plugin (https://github.com/bbecquet/Leaflet.PolylineOffset#usage) directly modifies the behavior of the L.Polyline
class. Since leaflet-gpx
simply creates the polyline by doing new L.Polyline(...)
, I believe the two should work just fine together.
To set the offset, you can either pass it through the polyline_options
when initializing the L.GPX
layer:
var gpx = new L.GPX(url, {
polyline_options: {
offset: 42
}
});
Or, you can set the offset after the fact. leaflet-gpx
fires an addline
event with the polyline in the event data:
var gpx = new L.GPX(url, ...).on('addline', function(event) {
event.line.setOffset(42);
});
Hi Maxime, tried with first option and works smoothly.
var gpx = new L.GPX(url, { polyline_options: { offset: 42 } }); Thank you again!
Hi, is it possible to use PolylineOffset with a GPX track, because that plugin adds offset capabilities to a L.Polyline class.? I intend to add a parallel line to the track path. In that case, is there any code example o demo I can take a look to? Thank you!