jjwtay / leaflet.sector

Leaflet Sector support
Apache License 2.0
7 stars 4 forks source link

Editing does not throw events #1

Open artuska opened 3 years ago

artuska commented 3 years ago

If i enable shape editing with enableEdit method:

shape.enableEdit();

then i dont't get Leaflet.sector's special vertices so i can drag them and change the sector.

If i enable shape editing with editing.enable method:

shape.editing.enable();

then Leaflet.sector's editing vertices appears so i can drag them and edit the sector but there are absolutely no any editing events thrown which are listed in Leaflet's Edit documentation at http://leaflet.github.io/Leaflet.Editable/doc/api.html -- there are no editable:editing and no editable:vertex:* events are thrown when i edit the sector.

So, how do i get editable events working?

jjwtay commented 3 years ago

Sorry the project I had been working on these for was paused for the past 2 years and only restarted this week so trying to re catch up. This and the corresponding shapes were not based on Leaflet.Editable but were instead based on prior work built out of Leaflet.Draw https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html

This specific library only handles rendering the sector to handle editing you need the corresponding edit library https://github.com/jjwtay/leaflet.draw-sector

While Leaflet.Edit's API is shape.enableEdit() Leaflet.Draw is based off shape.editing.enable() so that is the correct method and instead of Leaflet.Edit's event hooks leaflet.draw-sector bases it all off the event 'edit' (if i remember correctly that is) and you then get access to the shape and need to pull the data out yourself example:

shape.on('edit', (evt) => {
    // {
    //     center: evt.target.getCenter(),
    //     innerRadius: convertToNauticalMile(evt.target.getInnerRadius(), 'm'),
    //     outerRadius: convertToNauticalMile(evt.target.getOuterRadius(), 'm'),
    //     leftBearing: correctBrg(evt.target.getStartBearing()),
    //     rightBearing: correctBrg(evt.target.getEndBearing())
    // }
}
artuska commented 3 years ago

Great, edit event works! Well, in fact it throws at the end of editing when i drag and then mouseup some of the sector's vertices.