清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
//圆形范围关键字搜索
this.SearchCircle = function(keyWords) {
if (this.flag == false) {
this.flag = true;
this.currentCircle = new BMap.Circle(this.currentCenterPoint, this.currentDistance, {
strokeColor: "#0075C7",
strokeWeight: 1,
fillColor: "blue",
fillOpacity: 0.2,
strokeOpacity:0.5
}); //创建圆
this.currentBdMap.addOverlay(this.currentCircle);
}
var locals = new BMap.LocalSearch(this.currentBdMap, {
renderOptions: {
map: this.currentBdMap,
autoViewport: false
}
});
var bounds = getSquareBounds(this.currentCircle.getCenter(), this.currentCircle.getRadius(), this.currentBdMap);
locals.searchInBounds(keyWords, bounds);
function getSquareBounds(centerPoi, r, map) {
var a = Math.sqrt(2) * r; //正方形边长
mPoi = getMecator(centerPoi, map);
var x0 = mPoi.x,
y0 = mPoi.y;
var x1 = x0 + a / 2,
y1 = y0 + a / 2; //东北点
var x2 = x0 - a / 2,
y2 = y0 - a / 2; //西南点
var ne = getPoi(new BMap.Pixel(x1, y1), map),
sw = getPoi(new BMap.Pixel(x2, y2), map);
return new BMap.Bounds(sw, ne);
}
//根据球面坐标获得平面坐标。
function getMecator(poi, map) {
return map.getMapType().getProjection().lngLatToPoint(poi);
}
//根据平面坐标获得球面坐标。
function getPoi(mecator, map) {
return map.getMapType().getProjection().pointToLngLat(mecator);
}
}