This is the fourth day of my participation in the August More text Challenge. For details, see:August is more challenging

Keyword Local search

  • Create an instance of the search class, where Location represents the retrieval area, and its type can be a string of map instance, coordinate point, or city name. When the parameter is a map instance, the retrieval location is determined by the central point of the current map, and the annotation of the search results is automatically loaded into the map, and the view level of the map can be adjusted. When the parameter is a coordinate, the retrieval position is determined by the position of the point. When the parameter is a city name, the search takes place within the city
  • Search (keyword: String | Array) according to the word or retrieve a retrieval. When the keyword is an array, multiple keyword queries are executed simultaneously. A maximum of 10 keywords are supported
var map = new BMapGL.Map("container"); Var point = new bmapgl. point (116.403963,39.915119); map.centerAndZoom(point, 15); map.enableScrollWheelZoom(true); var local = new BMapGL.LocalSearch(map, { renderOptions:{map: map} }); The local search (" park ")Copy the code

Multi-keyword search

Not only can support single keyword search but also can support multi-keyword search
  • SearchInBounds initiates a range search based on the range and the search term. Multi-keyword retrieval is performed simultaneously when the keyword is an array. Up to 10 keywords are supported. Multi-keyword retrieval is supported since version 1.2
Var myKeys = [" myKeys "]; var local = new BMapGL.LocalSearch(map, { renderOptions:{map: map, panel:"r-result"}, pageCapacity:5 }); local.searchInBounds(myKeys, map.getBounds());Copy the code
Rice without strings, hot pot ao ~

Regional key words

  • Bounds(sw: point ne:point)
Var pStart = new bmapgl. Point(116.274625,39.961627); Var pEnd = new bmapgl. Point(116.367474,39.988609); var pEnd = new bmapgl. Point(116.367474,39.988609); var bs = new BMapGL.Bounds(pStart,pEnd); // Specify the bounds locally. SearchInBounds (" hotel ", bs); var polygon = new BMapGL.Polygon([ new BMapGL.Point(pStart.lng,pStart.lat), new BMapGL.Point(pEnd.lng,pStart.lat), new BMapGL.Point(pEnd.lng,pEnd.lat), new BMapGL.Point(pStart.lng,pEnd.lat) ], {strokeColor:"blue", strokeWeight:6, StrokeOpacity: 0.5}); map.addOverlay(polygon);Copy the code