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
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 (LngLat) Starting Point Latitude and Longitude
destination (LngLat) Destination Latitude and Longitude
callback (WalkingCallback) When 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 (WalkingCallback) When 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
});