Document Maps JavaScript API Reference Manual Tool Category PolylineEditor

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

Attribute

Type

Description

createOptions

Object?

Newly created object style

editOptions

Object?

Editing style

controlPoint

Object?

Vertex style CircleMarkerOptions

midControlPoint

Object?

Midpoint style CircleMarkerOptions

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

Parameteroverlay (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

Event Name

Description

addnode

This event is triggered when a node is added

adjust

This event is triggered when a point on the polyline is adjusted

removenode

This event is triggered when a node is deleted

add

This event is triggered after creating a polyline, and the target is the created object. When the editor's editing object is empty, calling the open interface and clicking the screen once will create a new overlay object

end

This event is triggered after calling close, and the target is the edited overlay object

For event object property descriptions, go to:MapsEvent