Document Maps JavaScript API Reference Manual Routes Transfer

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

Attribute

Type

Description

map

Map

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

city

string

We currently support specifying the starting city for both intra-city public transit transfers and cross-city public transit.

Optional Values: City Name/City Code,

policy

number

Public transport transfer strategy

nightflag

boolean

Whether to calculate night buses, default is false: do not calculate. true: calculate, false: do not calculate

extensions

string

Default value: base, returns basic address information. When the value is all, returns DriveStep basic information + DriveStep detailed information

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 starting point icon of the route planning to be hidden. Set to true: hide the icon; set to false: show the icon. Default value: false

isOutline

boolean?

Whether to display the stroke of the planned route drawn when using the map property. Default is true

outlineColor

string?

The stroke color of the planned route drawn when using the map property. Default is 'white'

autoFitView

boolean?

Used to control whether to automatically adjust the map view to make the drawn route within the visible range of the viewport after route planning is completed

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 (LngLatStarting point latitude and longitude

destination (LngLatEnd point latitude and longitude

callback (TransferCallbackWhen 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 (TransferCallbackWhen 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

Parameterpolicy (TransferPolicyPublic Transit Transfer Strategy

Demo:

transfer.setPolicy(0);

setCity(city)

Set the city for the bus transfer query

Parametercity (StringCity

Demo:

transfer.setCity("764010000");

setCityd(cityd)

Set the destination city for the bus transfer query

Parametercityd (StringCity

Demo:

transfer.setCityd("764010000");

Event

Event Name

Description

complete

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

error

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