标签:
//定义要素组存放marker
var picGroupMarker = new L.featureGroup();
//marker自定义图片.另外,className可以自定义icon的显示样式,如闪烁等.
var imgIcon = new L.icon({
iconUrl: ‘images/marker-icon.png‘,
iconRetinaUrl: ‘images/marker-icon@2x.png‘,
iconSize: [25, 41],
className: ‘‘,
iconAnchor: [22, 94],
popupAnchor: [-3, -6],
shadowUrl: ‘images/marker-shadow.png‘,
shadowRetinaUrl: ‘images/marker-shadow@2x.png‘,
shadowSize: [68, 95],
shadowAnchor: [22, 94]
});
//创建marker,注意坐标点对纬度在前,经度在后.
var myMarker = L.marker([lat,lng], {icon: imgIcon});
//marker添加到要素组
myMarker.addTo(picGroupMarker);
//要素组添加到地图
picGroupMarker.addTo(map);
//移除所有marker
map.removeLayer(picGroupMarker);
//移除之后重新添加,需要picGroupMarker为全局变量
map.addLayer(picGroupMarker);
标签:
原文地址:http://www.cnblogs.com/eastcom/p/5725737.html