高德地图二次删除一次Marker 试了网上很多办法都不可行 求大神

qq_37269825 2018-01-10 10:17:09
//初始化地图对象,加载地图
function mapInit(){
mapObj = new AMap.Map("container",{
//二维地图显示视口
view: new AMap.View2D({
center:new AMap.LngLat(w,ww),//地图中心点
resizeEnable: true,
zoom:13 //地图显示的缩放级别
})
});

//添加点标记,并使用自己的icon
addMarker1();
/* addMarker2();
addMarker3();*/
}

//在地图上添加点标记函数
function addMarker1(){
var as=$("#user_name").val();
$.post("../MapAction/police.html",{"username":as},function(mes){
var dataObj = eval("(" + mes + ")"); // 转换为json对象
$.each(dataObj, function (i,item){
var g=item.long_lat.split(',');
var dd=g[0];
var ddd=g[1];
asb=item.long_lat;
marker=new AMap.Marker({
icon:new AMap.Icon({ //复杂图标
size:new AMap.Size(40,40),//图标大小
image:"../image/dingwei.gif", //大图地址
imageOffset:new AMap.Pixel(0,0)//相对于大图的取图位置
}),
position:new AMap.LngLat(ddd,dd)
});
marker.setMap(mapObj); //在地图上添加点


});
});
}

</script>
</head>
<body onLoad="mapInit()">
<div id="container" style="width:100%; height:95%; ">
<div id="ShowAD" style="position:absolute;z-index:100;width:100%;height:100%;">

</div>
</div>

<input type="hidden" id="user_name" name="user_name" value="${sessionScope.users.userName}">

<input type="hidden" id="mingc" name="mingc" value="">
<div class="map_sta">
<div class="ms">

<s class="x"></s>
</div>
</div>
</body>
</html>
...全文
376 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧