let local = new BMap.LocalSearch('北京', { //设置搜索区域 可为这个整个地图
onMarkersSet:function (array) {
console.log(array);
},
onInfoHtmlSet:function (LocalResultPoi) {
console.log(LocalResultPoi);
},
onResultsHtmlSet:function (element) {
console.log(element);
},
onSearchComplete:function(results){
let arrPoint=[]
results=results.Ar
if(results==0){
alert('暂无搜索结果')
}
for(let i=0;i<results.length;i++){
arrPoint.push(results[i].point)
let myIcon = new BMap.Icon('iconsrc', new BMap.Size(48,48),{// 自定义icon的图标
imageSize:new BMap.Size(48,48)
});
let marker2 = new BMap.Marker(results[i].point,{icon:myIcon});
that.mapObj.addOverlay(marker2);
}
that.mapObj.setViewport(arrPoint)
}
});
local.search(detailAddress,
{forceLocal:true})