在 Leaflet.js 文档中,记录了一个带有标记层的示例。我想以 GeoJSON 格式创建一层多边形。这可能吗?
我为每个 GeoJSON 多边形定义了一个变量,称为 route1、route2 等。我的 .js 文件如下所示:
var map = L.map('map', {
center: [55.676098, 12.568337],
});
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
//============
//Create layer
//============
var Southroutes = new L.layerGroup([route1, route2, route3, route4, route5]);
L.geoJSON(Southroutes).addTo(map);