DragRoute
AMap.DragRoute
Driving route planning drag-and-drop plugin, supports editing routes by dragging. Construct a driving route planning drag-and-drop plugin object, and set the properties of the plugin object through DragRouteOptions
new AMap.DragRoute(map: Map, path: Array<LngLat>, policy: Number, opts: DragRouteOptions)Parameter
map (Map): Specified map object
path (Array<LngLat>): Array of latitude and longitude coordinates for the start, waypoints, and end of navigation
policy (Number): Specify driving strategy
opts (DragRouteOptions): Configuration items
Demo
AMap.plugin("AMap.DragRoute", function () {
//Draw initial path
var path = [];
path.push([100.491422, 13.749313]);
path.push([100.482731, 13.745401]);
path.push([100.49, 13.74]);
route = new AMap.DragRoute(map, path, 0); //Construct a drag navigation class
route.search(); //Query the navigation path and enable drag navigation
});Method
search()
Start route navigation. Supports dragging navigation path nodes with the mouse. When changing waypoints, the system recalculates and displays the navigation path in real time
Demo:
route.search();getWays()
Return all waypoints of the navigation except the start and end points, i.e., the coordinate array of all waypoints
return value: (Array<LngLat>) All waypoint coordinates
Demo:
route.getWays();getRoute()
Return the current navigation path, which is an array of latitude and longitude coordinates of the navigation path
return value: (Array<LngLat>) Current navigation path
Demo:
route.getRoute();destroy()
Destroy the drag navigation plugin
Demo:
route.destroy();Event
For event object property descriptions, go to:MapsEvent