百度地图 JSAPI使用 mark 定位地址 与周边覆盖物
var map = new BMap.Map("container");
var preMarker = new BMap.Marker();
map.addControl(new BMap.NavigationControl());//启用缩放轴
map.addControl(new BMap.ScaleControl());//启用距离监测
var myGeo = new BMap.Geocoder(); //创建地址解析实例
myGeo.getPoint("${house.mapLocateaddress}", function (point) {
if (point) {
mPoint = new BMap.Point(point.lng, point.lat);
map.centerAndZoom(mPoint, 16);
displayPOI();
} else {
myGeo.getPoint("${house.mapLocateaddress2}", function (point) {
if (point) {
mPoint = new BMap.Point(point.lng, point.lat);
map.centerAndZoom(mPoint, 16);
displayPOI();
}
}, "广东省");
}
}, "广东省"); //必须设置城市
/* map.enableScrollWheelZoom(); //启用滚轮缩放*/
var mOption = {
poiRadius: 10000, //半径为1000米内的POI,默认100米
numPois: 30 //列举出50个POI,默认10个
}
//POI导航选中样式
$("#map-indicator a").click(function () {
$("#map-indicator a").removeClass("on");
$(this).addClass("on");
$("#env-list h3").text($("#map-indicator .on").html());
displayPOI();
})
var allPois;
var markers=[];
function displayPOI() {
map.clearOverlays();
var poiType = $("#map-indicator .on").html();
var circle = new BMap.Circle(mPoint,500,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.1, strokeOpacity: 0.1});
map.addOverlay(circle);
var local = new BMap.LocalSearch(map, {renderOptions: {map: map, autoViewport: false,panel: "map-result-list"}});
local.searchNearby(poiType,mPoint,500);
}
posted on 2017-03-22 08:58 signheart 阅读(1424) 评论(0) 编辑 收藏 举报