PlaceSearch
AMap.PlaceSearch
Location search service plugin, providing location query services for a specific area. Construct a location search service plugin object
AMap.PlaceSearch(opts:PlaceSearchOptions)Parameter
opts (PlaceSearchOptions): Location Search Parameters
Demo
AMap.plugin(["AMap.PlaceSearch"], function () {
var PlaceSearchOptions = {
city: "840380000",
type: "博物馆",
pageSize: 10,
pageIndex: 1,
extensions: "base",
};
var placeSearch = new AMap.PlaceSearch(PlaceSearchOptions);
placeSearch.search("food", function (status, result) {
console.log(result);
});
});Method
search(keyword, callback)
Match information based on input keyword prompts
Parameter:
keyword (string) Keyword
callback (searchCallback) Search results callback
Demo:
placeSearch.search("food", function (status, result) {
console.log(result);
}); searchInBounds(keyword, bounds, callback)
Perform a range search based on the scope and keyword
Parameter:
keyword (string) Keyword
bounds (Bounds) Range
callback (searchCallback) Search results callback
Demo:
var polygonArr = [
[-73.509092,40.793609],
[-73.487738,40.769018],
[-73.446643,40.768289],
[-73.424987,40.793844],
];
placeSearch.searchInBounds("food", polygonArr, function (status, result) {
console.log(result);
});searchNearBy(keyword, center, radius)
Perform a nearby search based on the center point latitude and longitude, radius, and keyword. The radius range is 0-50000
Parameter:
keyword (string) Keyword
center (LngLat) Center Point Latitude and Longitude
radius (number) Radius
Demo:
var cpoint = [103.861974,1.304754];
MSearch.searchNearBy("food", cpoint, 2000, function (status, result) {
console.log(result);
});getDetails(PGUID)
Query POI Details Based on PGUID
Parameter:
PGUID (string) PGUID
Demo:
placeSearch.getDetails("P0JAK55X50", function (status, result) {
console.log(result);
});setType(type)
Set Query Categories, Multiple Categories Separated by "|"
Parameter: type (string) Category
Demo:
placeSearch.setType('餐饮服务');setPageIndex(pageIndex)
Set Display Result Page Number
Parameter: pageIndex (number) Result Page Number
Demo:
placeSearch.setPageIndex(1);setPageSize(pageSize)
Set the number of query results displayed per page
Parameter: pageSize (number) Number of query results displayed per page
Demo:
placeSearch.setPageSize(10);setCity(city)
Set the query city, supports cityname (Chinese or full Pinyin), citycode, adcode
Parameter: city (string) City identifier
Demo:
placeSearch.setCity('beijing');setCityLimit(citylimit)
Set whether to enforce city restrictions
Parameter: citylimit (boolean) Whether to enable
Demo:
placeSearch.setCityLimit(true);Event
selectChanged
Triggered when the selected POI changes after using map and panel properties
Parameter: event (object) Return parameters
markerClick
Triggered when the Marker corresponding to the POI on the map is clicked after using the map and panel properties
Parameter: event (object) Return Parameters
listElementClick
When the list item corresponding to the POI in the result panel is clicked after using the map and panel attributes
Parameter: event (object) Return Parameters