Wechat: yu389741| Email: gisdqy@163.com

Shop:https://www.giserdqy.com/shop

leaflet 自定义图标



// 添加当前位置 标注
		var icon = new L.Icon({
		  iconUrl: 'leaflet/images/marker-icon.png',
		  shadowUrl: 'leaflet/images/marker-shadow.png',
		  iconSize: [25, 41],
		  iconAnchor: [12, 41],
		  popupAnchor: [1, -34],
		  shadowSize: [41, 41]
		});
		var locationMarker = L.marker(map.getCenter(), {icon: icon}).addTo(map);
		//点击地图上任意另一个点,锚点跟过去,当前坐标值跟着变换;
		map.on('click', function(e) {
			var latlng = e.latlng;
			// alert('纬度:'+latlng['lat']+';经度:'+latlng['lng']);
			locationMarker.slideTo([latlng['lat'], latlng['lng']], {
				duration: 500
			});
			map.setView([latlng['lat'], latlng['lng']]);
		}); 

转载自:https://blog.csdn.net/qq_36061522/article/details/87168605