//圆形范围关键字搜索
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);
}
}
XHTMT|
HTML5|
CSS|
HTML DOM|
jQuery|
JSON|
AJAX|
LESS|
HTML|
Bootstrap|
Foundation|
AngularJS|
Ember.js|
TypeScript|
AngularJS2|
React|
jQuery UI|
jQuery EasyUI|
Node.js|
Highcharts|
Echarts|
Vue.js|
CoffeeScript|
Ext.js|
Meteor|
SASS|
Omi|
Markdown|
前端开发规范|
浏览器|
webpack|
JavaScript|
CSS3|
用户登录
还没有账号?立即注册
用户注册
投稿取消
| 文章分类: |
|
还能输入300字
上传中....
温颠唉