for (var i = 0; i < RegionData.length; i++) { (function () { var icon = new BMap.Icon(‘../../assets/images/arrow_right.png‘, new BMap.Size(20, 32) , {anchor: new BMap.Size(8, 8) }); var mkr = new BMap.Marker(new BMap.Point(RegionData[i].longitude, RegionData[i].latitude) , {icon: icon}); mkr.setTitle(RegionData[i].name); map.addOverlay(mkr);//map指地图实例 })();//这句立即执行很重要,否则你会发现只给最后一个标注加了监听 }
本文出自 “银翼神驹” 博客,请务必保留此出处http://leesolo.blog.51cto.com/2672511/1954410
原文地址:http://leesolo.blog.51cto.com/2672511/1954410