Document Maps JavaScript API Reference Manual Routes Walking

Walking

AMap.Walking

Walking route planning, providing start and end point walking route planning services. Construct a walking route planning object and set the properties of the service object through WalkingOptions

new AMap.Walking(opts: WalkingOptions)

Parameter

opts(WalkingOptions): Walking route planning parameters

Attribute

Type

Description

map

Map

AMap.Map object, the map instance that displays the results. When this parameter is specified, the annotations and routes of the search results will be automatically added to this map. Optional

panel

string | HTMLElement

The HTML container ID or container element of the result list. After providing this parameter, the result list will be displayed in this container. Optional

hideMarkers

boolean

Set the start point icon of the hidden route planning to true: hide the icon; set to false: show the icon. Default value: false

isOutline

boolean?

When using the map property, whether the planned route displays a stroke. Default is true

outlineColor

string?

When using the map property, the stroke color of the planned route. Default is 'white'

autoFitView

boolean?

Used to control whether the map view is automatically adjusted after route planning to make the drawn route visible within the viewport

Demo

AMap.plugin("AMap.Walking", function () {
  var walking = new AMap.Walking({ map: map });
  walking.search(
    [135.781008,34.9966644],
    [135.772618,35.0059184],
    function (status, result) {
      // result is the corresponding walking route data information
      if (status === "complete") {
        console.log("Walking route drawing completed");
      } else {
        console.log("Failed to query walking route data" + result);
      }
    }
  );
});

Method

clear()

Clear search results

Demo:

walking.clear();

search(origin, destination, callback)

Plan walking routes based on starting and destination coordinates

Parameter:

origin (LngLatStarting Point Latitude and Longitude

destination (LngLatDestination Latitude and Longitude

callback (WalkingCallbackWhen the status is complete, the result is WalkingResult; when the status is error, the result is the error info; when the status is no_data, it means the search returned 0 results

Demo:

walking.search(
  [135.781008,34.9966644],
  [135.772618,35.0059184],
  function (status, result) {
    //status: complete indicates a successful query, no_data indicates no results found, error indicates a query error
    //When the query is successful, the result is the corresponding walking route information
  }
);

search(points, callback)

Implement walking route planning based on the names of the starting point and destination

Parameter:

points (Array<Object>The points of latitude and longitude for the destination are an array of the starting point, destination, and optional waypoints with their corresponding cities, for example: [{keyword:'Fangheng International Center Building A'},{keyword:'Wangjing Station'}] The system takes the first and last elements of the array as the starting point and destination, and the middle elements as waypoints

callback (WalkingCallbackWhen status is complete, the result is WalkingResult; when status is error, the result is the error info; when status is no_data, it means the search returned 0 results

Demo:

walking.search([
  { keyword: '2 Na Phra Lan Rd, Khwaeng Phra Borom Maha Ratchawang', city: '764010000' },
  { keyword: '34 Wang Doem Rd, Khwaeng Wat Arun', city: '764010000' },
], function(status, result) {
  //status: complete indicates a successful query, no_data indicates no results, and error indicates a query error
  //When the query is successful, the result is the corresponding walking route information
});

Event

Event Name

Description

complete

This event is triggered when the query succeeds(Type: WalkingResult

error

This event is triggered when the query fails(Type: ErrorStatus