开发 Maps JavaScript API Reference Manual Geocoding Geocoder

Geocoder 最后更新时间: 2026年07月02日

AMap.Geocoder

Geocoding and reverse geocoding class, used for conversion between address descriptions and latitude/longitude coordinates. Users can obtain query results through callback functions. Construct a geocoding and reverse geocoding object, and set its properties through GeocoderOptions.

new AMap.Geocoder(opts: GeocoderOptions)

Parameter

options (GeocoderOptions): Geocoding and reverse geocoding parameters

Attribute

Type

Description

city

string

City. During geocoding, set the city where the address description is located. Optional values: citycode, adcode. City code table

radius

number

During reverse geocoding, the range centered on the given coordinates, in meters.

 Value range: 0 - 3000. 

Default: 1000

lang

string

Set language type. 

Optional values: zh_cn (Chinese), en (English). 

Default: zh_cn (Chinese)

batch

boolean

Whether to batch query; 

when batch is set to false, only the first record is returned

extensions

string

When reverse geocoding, the level of detail in the returned information defaults to 'base', returning basic address information; set to 'all', it returns address information along with nearby POIs, roads, road intersections, etc.

Demo

AMap.plugin("AMap.Geocoder", function () {
  var geocoder = new AMap.Geocoder({
    radius: 1000, 
    extensions: "all", 
  });
  var lnglat = [-73.98751,40.74129];
  geocoder.getAddress(lnglat, function (status, result) {
    if (status === "complete" && result.info === "OK") {
      // result is the corresponding detailed geographic information
    }
  });
});

Method

getLocation(keyword, cbk)

Convert address information into Gaode latitude and longitude coordinates

Parameter:

keyword (String) Keyword

cbk (GeocoderCallback) Callback function

Demo:

var address = "9, Madison Avenue, 曼哈顿, 纽约, 纽约州, 美国";
geocoder.getLocation(address, function (status, result) {
  if (status === "complete" && result.info === "OK") {
    // result is the corresponding detailed geographic information
  }
});

setCity(city)

When geocoding, set the city for the address description

Parameter: city (String) City

Demo:

geocoder.setCity("010");

getAddress(location, cbk)

Convert latitude and longitude coordinates into structured address information

Parameter:

location(LngLat | Array<LngLat>) Given coordinates

cbk (ReGeocoderCallback) Callback function

Demo:

var lnglat = [116.396574, 39.992706];
geocoder.getAddress(lnglat, function (status, result) {
  if (status === "complete" && result.info === "OK") {
    // result is the corresponding detailed geographic information
  }
});

返回顶部 示例中心 常见问题 智能客服 公众号
二维码