Demos
Each demo lists what the library provides and what the application, here the demo's own code, implements.
-
Large polyline
Editing a 10,000-point track.
- Library
- Editor markers only for the points around the selected point (up to 201), so the map stays responsive. Dragging a point moves it, dragging a midpoint inserts a new point, and right-clicking (long-press on touch devices) a point deletes it. Editing can be enabled and disabled, and the editable range can be set for each editing session.
- Application
- Starts editing when the line is clicked and ends it when the map is clicked. Provides the enable/disable toggle and the editable-range selector.
-
Syncing application data
The polyline is only a temporary editing aid; the application owns the data.
- Library
-
Reports each move, insertion and deletion as an event with the
point's index and coordinates, and accepts new geometry through
setLatLngs(). It handles latitude and longitude only, not elevation. - Application
- Keeps the data, including elevation. Draws the original line, swaps in the editor when it is clicked, applies each event to the data using its index (interpolating the elevation of inserted points), and shows the result in the table.
-
Undo / redo
Undo and redo of point moves, insertions and deletions.
- Library
-
Reports each operation as an event with its index and, for moves,
the previous and new coordinates, and accepts new geometry through
setLatLngs(). It has no undo or redo of its own. - Application
-
Records the history, replays each operation in reverse or forward
on its own data, pushes the result back with
setLatLngs(), and provides the buttons and keyboard shortcuts (Ctrl/Cmd+Z, Ctrl/Cmd+Shift+Z or Ctrl+Y).
-
Multiple polylines
Several routes, each with its own data.
- Library
- Each polyline is an independent editor with its own editing session and events. Editing can be enabled and disabled per polyline.
- Application
- Keeps each route's data, switches the editing target by ending the current session and starting the next, tracks which route is being edited, and provides the lock checkboxes.