这里实现了一个指定地区的地图,自定义图标,点击切换图标
1.[代码][JavaScript]代码
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
拖拽地图// 百度地图API功能
$(function(){
var map = new BMap.Map('allmap');
var point = new BMap.Point(105.591334,30.538084);
map.centerAndZoom(point,13);
map.enableScrollWheelZoom(true);
map.enableDragging();
var data_infon = [
[105.60068,30.507482],
[105.56738,30.547487],
[105.576523,30.531523],
[105.616707,30.523279],
[105.61777,30.527915]
];
var icon = new BMap.Icon("blueImg.png", new BMap.Size(61, 40));
for( var i = 0;i
var marker = new BMap.Marker(new BMap.Point(data_infon[i][0],data_infon[i][1]),{
icon: icon
});
map.addOverlay(marker);
}
makerClick();
function makerClick(){
var z_index=$(this).css("z-index");
$(".BMap_Marker").each(function(){
if($(this).css("z-index")==z_index){
if(!$(this).hasClass("BMap_noprint")){
if(img){$(img).attr("src","images/blueImg.png")}
$(this).find("img").attr("src","images/redImg.png");
img=$(this).find("img")[0];
}
}
});
}
})