百度地图api,点击标注,改变标注marker图标的链接地址
改变选中的图标样式
// 选中高亮标注图片 let mapIcon = ‘./icon.png’; //标注点 let markerArrs = [{},{},....]; // 点击标注点 marker.addEventListener("click", (evt) => { for (let j = 0; j < markerArrs.length; j++) { const element = markerArrs[j]; // 初始化点的时候绑定customId let ids = evt.target ? evt.target.id : evt.customId; if( ids === element.id){ element.setIcon(new BMap.Icon(mapIcon, new BMap.Size(24,39))); }else{ // 初始化点的时候绑定初始化iconSrc标注地址 element.setIcon(new BMap.Icon(element.iconSrc, new BMap.Size(24,39))); } } }
简单例子
//简单点说明 var pointAIcon2= new BMap.Icon(url2, new BMap.Size(28,28)); markerArm.addEventListener("click",function () { this.setIcon(pointAIcon2); });
相关推荐
etzt 2020-04-16
etzt 2020-01-06
jishume 2011-07-19
xcjing 2015-11-12
XiaoyiXie 2019-04-25
xiaoshe 2014-07-10
蓝色诱惑 2014-07-10
zmosquito 2016-11-21
zmosquito 2015-05-20
nutian 2016-07-04
chang00 2013-05-02
bingxingke 2013-01-28
zmosquito 2013-01-23
semjinghua 2012-12-14
geminihr 2012-11-14
bingxingke 2012-05-17
channeldotren 2018-01-26
qrcwkt 2017-11-06