您的位置:首页 > 其它

【leaflet】地图显示、标记、图层切换

2016-02-03 18:23 246 查看
leaflet

地图和marker显示:http://leafletjs.com/examples/quick-start.html

marker自定义图片:http://leafletjs.com/examples/custom-icons.html

图层切换(控制):http://leafletjs.com/examples/layers-control.html(其中cities的marker数组是option,可以删去)

具体文档:http://leafletjs.com/reference.html#marker

----------------------------------------------------------------------------------------------------------------------------------------------

移除Marker:

思路》》把marker放到layer中,删除layer,因为Marker实现了ILayer接口

添加时:map.addLayer(marker); //而不用marker.addTo(map);

删除时:map.removeLayer(marker);

Geojson图层:

//画导航线路
function drawGeojson(json){
	if(map.hasLayer(routeline)){
		map.removeLayer(routeline);		
	}

	var route = [{
		"type": "LineString",
		"coordinates": json
	}];

	routeline = L.geoJson(route,{style:{"color": "#FF7F00",	"weight": 5,"opacity": 0.65	}});

	map.addLayer(routeline);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: