POI Search API

From Automotive and Web Platform Business Group

Map Viewer API Example


Name Space

AMap is the namespace of Alibaba LBS JS API. All the classes and objects are called by AMap.XXX

For instance, to construct a LngLat object:

new AMap.LngLat(116.397428,39.90923);

PlaceSearch Class

Function: Provide place search service within a given region.

[Constructor]
// To create a PlaceSearch object
PlaceSearch(PlaceSearchOptions opts)

Params:

  • opts: type PlaceSearchOptions, carrying the list of placeSearch initialization parameters

PlaceSearchOptions

PlaceSearch Options Type Description
city String City of POI. Format can be as city name or city code or administrative code
type String Type of POI. If more than one, separate by ‘|’, like ‘Cinema | Hotel’
extentions String ‘base’: return basic POI info;‘all’: return basic and detailed POI info

PlaceSearch Class - Methods

Method Return Description
search(String keyword, callback: function(String status, SearchResult result | String info)) Void Search the POI according to keyword. There is a callback function. If status is ‘complete’, then POI result is returned; if status is ‘error’, then error info is returned
searchNearBy(String keyword, LngLat center, Number radius, callback: function(String status, SearchResult result | String info)) Void Search the POI according to map center point coordinates, radius and keyword
searchInBounds(String keyword, Bounds bounds, callback: function(String status, SearchResult result | String info)) Void Search the POI according to bounds and keyword
getDetails(String PGUID, callback: function(String status, SearchResult result | String info)) Void Search the POI according to PGUID, which is ID of POI item
setType(String type) Void Set POI type. If more than one, separate by ‘|’
setCity(String city) Void Set city. Format can be as city name or city code or administrative code

SearchResult Class

Attribute Type Description
info String Status of result
poiList PoiList POI list
keywordList Array.<String> Keyword list. If no match is found according to the given keyword, then return the suggested keyword list
cityList Array.<CityInfo> City list. If no match is found according to the given keyword, then return the suggested city list. Each city item contains at least one POI item

PoiList Class

Attribute Type Description
pois Array.<Poi> List of POI
count Number Total number of POI results

CityInfo Class

Attribute Type Description
name String City name
citycode String City code
adcode String Administrative region code
count Number Total number of POI results of this city

Poi Class

Basic info:

Attribute Type Description
id String ID of POI item
name String POI name
type String POI type
location LngLat Coordinates of POI
address String Address of POI
distance Number Distance from map center
tel String Tel info of POI

Detailed info:

Attribute Type Description
website String Website of POI
pcode String Province code of POI
citycode String City code of POI
adcode String Administrative region code of POI
postcode String Postcode of POI
pname String Province name of POI
cityname String City name of POI
adname String Administrative region name of POI
email String Email of POI
entr_location LngLat Entrance coordinates of POI, if there is an entrance
exit_location LngLat Exit coordinates of POI, if there is an exit

POI Search Example

var MSearch;
AMap.service(["AMap.PlaceSearch"], function() {
  MSearch = new AMap.PlaceSearch({ //Construct PlaceSearch object
   pageSize:10, pageIndex:1, city:"010" //Beijing
  });
  MSearch.search(, function(status, result){ //keyword search
   if(status === 'complete' && result.info === 'OK'){
    var poiArr = result.poiList.pois;
    var resultCount = poiArr.length;
    for (var i = 0; i < resultCount; i++) {
     console.log(“Type: ” + poiArr[i].type + “Address: ” + poiArr[i]);
    }
   }
  });
});