PolylineEditor
AMap.PolylineEditor
Polyline editing plugin, used to edit AMap.Polyline objects, supports adjusting the shape of the polyline with the mouse. Construct a polyline editing plugin object.
new AMap.PolylineEditor(map: Map, polyline: Polyline?, opts: Object?)Parameter
map (Map): Map instance
polyline (Polyline?): Edit object
opts (Object?): Set parameters
Demo
//Import the polyline editor plugin
map.plugin(["AMap.PolylineEditor"], function () {
//Instantiate the polyline editor, passing in the map instance and the polyline instance to be edited
polylineEditor = new AMap.PolylineEditor(map, polyline);
//Enable edit mode
polylineEditor.open();
});Method
setTarget(overlay?)
Set the editing object
Parameter: overlay (Polyline?) Instantiated object for editing
Demo:
//Create a polyline instance
var path = [
new AMap.LngLat(116.368904, 39.913423),
new AMap.LngLat(116.382122, 39.901176),
];
var polyline = new AMap.Polyline({ path: path });
map.add(polyline);
//Instantiate the polyline editor, passing in the map instance and the polyline instance to be edited
polylineEditor = new AMap.PolylineEditor(map);
//Set polyline2 as the polyline instance to be edited
polylineEditor.setTarget(polyline);
polylineEditor.open();getTarget()
Get editing object
return value: (Polyline | undefined) Currently editing object
Demo:
polylineEditor.getTarget();open()
Start editing object
Demo:
polylineEditor.open();close()
Stop editing object
Demo:
polylineEditor.close();Event
For event object property descriptions, go to:MapsEvent