Transfer
AMap.Transfer
Currently, bus transfers only support bus route planning within the same city. For cross-city travel planning, please refer to the driving navigation query. The bus transfer query results integrate walking information. If the transfer segment (Segment) type is subway "SUBWAY", it will include at least one subway entrance information (SubwayEntrance). Users can retrieve and display the query results through a custom callback function.
Construct a bus route planning service object, and set the properties of the service object through DrivingOptions.
new AMap.Transfer(opts: TransferOptions)Parameter
opts(TransferOptions): Bus route planning parameters
Demo
AMap.plugin("AMap.Transfer", function () {
var transOptions = {
map: map,
city: "东京",
};
var transfer = new AMap.Transfer(transOptions);
transfer.search(
new AMap.LngLat(135.781008,34.9966644),
new AMap.LngLat(135.772618,35.0059184),
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 route planning information
}
);
});Method
search(origin, destination, callback)
Perform public transit transfer query based on the starting and ending coordinates
Parameter:
origin (LngLat) Starting point latitude and longitude
destination (LngLat) End point latitude and longitude
callback (TransferCallback) When the status is complete, the result is DrivingResult; when the status is error, the result is the error information info; when the status is no_data, it means the search returned 0 results
Demo:
transfer.search(
new AMap.LngLat(135.781008,34.9966644),
new AMap.LngLat(135.772618,35.0059184),
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 route planning information
});search(points, callback)
Query public transit routes based on the coordinates of the start and end points
Parameter:
points (Array<Object>) When querying based on the names of the start and end points, point is an array containing the start and end points
callback (TransferCallback) When the status is complete, the result is DrivingResult; when the status is error, the result is the error information info; when the status is no_data, it means the search returned 0 results
Demo:
transfer.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 route planning information
});leaveAt(time, date)
Set Public Transit Route Planning Departure Time
Parameter:
time (string)
date (string)
clear()
Clear Result Display
Demo:
transfer.clear();setPolicy(policy)
Set Public Transit Transfer Strategy
Parameter: policy (TransferPolicy) Public Transit Transfer Strategy
Demo:
transfer.setPolicy(0);setCity(city)
Set the city for the bus transfer query
Parameter: city (String) City
Demo:
transfer.setCity("764010000");setCityd(cityd)
Set the destination city for the bus transfer query
Parameter: cityd (String) City
Demo:
transfer.setCityd("764010000");