L.Pather icon indicating copy to clipboard operation
L.Pather copied to clipboard

addPolyline

Open knownasilya opened this issue 8 years ago • 3 comments

Would love to be able to repopulate the paths into pather without triggering 'created'. So currently the only way is to use createPath which triggers the 'created' event. But I already have the polylines and would just like to add them. So having something like:

pather.addPolyline(polyline)
// `polyline` is instance of `L.Pather.Polyline`
// this triggers 'added' event instead

The alternate approach is to check every latlng of every line against a current list to make sure duplicates aren't added.

I also tried pather.polylines.push(polyline) but the line isn't added to the map for some reason.

I'll submit a PR if this sounds like something you'd 📦

knownasilya avatar Dec 30 '16 21:12 knownasilya

Found a workaround for now:

markup.forEach(item => {
  pather.polylines.push(item.polyline);
  item.polyline.redraw(item.polyline.edges);                                                                                                   
});  

Which basically points to the implementation I'd submit.

knownasilya avatar Dec 30 '16 22:12 knownasilya

Do you think an optional second argument to createPath would be acceptable?

createPath([...], false);

Wildhoney avatar Jan 03 '17 08:01 Wildhoney

@Wildhoney totally

knownasilya avatar Jan 03 '17 17:01 knownasilya