Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ID to points? #4

Open
brorfred opened this issue Mar 18, 2015 · 2 comments
Open

Add ID to points? #4

brorfred opened this issue Mar 18, 2015 · 2 comments

Comments

@brorfred
Copy link

Hi!

I love the idea with leaflet-plotter! My use case would be to edit waypoints for cruise planning when doing research cruises. I'm planning to read initial positions and write edits via AJAX.

The problem is that existing waypoints already has meta data attached to them. It would be fantastic to be able to keep an ID to each existing waypoint when initiating leaflet-plotter, so that it's possible to identify them at the end.

@scripter-co
Copy link
Owner

the internal array held of points can be accessed using plottedPolyline.getLatLngs();, can you not map these to your metadata or am I missing something?

Perhaps adding and removing events should trigger custom events, which would allow you to listen to leaflet.plotter.added/leaflet.plotter.removed and then you could send the points 0-indexed key to your ajax endpoint and make the relevant addition/deletion from your datastore.

Or maybe I'm missing your point completely ;)

@brorfred
Copy link
Author

Thanks for your response! The problem is that one can both change and add points at the same time. Assume the following list:

[[10,20],
[20,20],
[20,30]]

The user changes one point and add another:

[[10,20],
[20,25],
[20.27],
[20,30]]

I don't know which of the two values that is the original.

The simplest solution I could come up with is to add an ID:

[[0,10,20],
[1,20,20],
[2,20,30]]

leading to:

[[0,10,20],
[1,20,25],
[,20.27],
[2,20,30]]

I have no idea how hard that would be, or if I'm overthinking the problem... I do like your idea about added and removed events as well though!

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants