请参阅演示 UI,下面是更多示例。这也是uMap背后的绘图引擎。
安装
您需要 Leaflet >= 1.0.0,然后包含src/Leaflet.Editable.js
.
路径拖动
如果你想要路径拖动,你还需要包含Path.Drag.js。
快速开始
在地图选项中允许 Leaflet.Editable:
var map = L.map('map', {editable: true});
然后,要开始编辑现有功能,请在enableEdit
其上调用方法:
var polyline = L.polyline([[43.1, 1.2], [43.2, 1.3],[43.3, 1.2]]).addTo(map);
polyline.enableEdit();
如果你想画一条新线:
map.editTools.startPolyline(); // map.editTools has been created
// by passing editable: true option to the map
如果要继续现有线路:
polyline.editor.continueForward();
// or
polyline.editor.continueBackward();
Examples
- Basic controls
- Continue line by ctrl/command-clicking on first/last point
- Create hole in a polygon by ctrl-clicking on it
- Change line colour on editing
- Display a tooltip near cursor while drawing
- Basic demo of undo/redo (Use ctrl-Z to undo and ctrl-shift-Z to redo)
- Deleting shapes by ctrl/command clicking on it
- Multipolygon example
- Example of Leaflet.Snap integration to enable snapping
API
HomePage
GitHub - Leaflet/Leaflet.Editable: Make geometries editable in Leaflet.
Repository
GitHub - Leaflet/Leaflet.Editable: Make geometries editable in Leaflet.