Document Maps JavaScript API Reference Manual Routes DragRoute

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

Attribute

Type

Description

polyOption

PolylineOptions?

Set the route attribute object of the drag route plugin, including line style, width, color, etc., refer to the PolylineOptions list

startMarkerOptions

MarkerOptions?

Set the start point marker attribute object of the drag route plugin, including marker style, size, etc., refer to the MarkerOptions list

midMarkerOptions

MarkerOptions?

Set the via point marker attribute object of the drag route plugin, including marker style, size, etc., refer to the MarkerOptions list

endMarkerOptions

MarkerOptions?

Set the end point marker attribute object of the drag route plugin, including marker style, size, etc., refer to the MarkerOptions list

showTraffic

boolean

Set to display real-time traffic information, true: show real-time traffic information in the route, false: turn off real-time traffic information. Default: true

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

Event Name

Description

addway

Event triggered by adding a waypoint

complete

Event triggered when driving route planning is completed, data is the same as the result returned by Driving route planning DrivingResult

For event object property descriptions, go to:MapsEvent