add layer through layer group in debug page

This commit is contained in:
Mourner 2011-07-29 16:54:54 +03:00
parent 740be94032
commit 6b23b4325b

View File

@ -17,6 +17,7 @@
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
<button onclick="map.removeLayer(path)">Remove path</button>
<button onclick="map.removeLayer(circle)">Remove circle</button>
<button onclick="group.clearLayers()">Remove all layers</button>
<script src="route.js"></script>
@ -30,6 +31,8 @@
var path = new L.Polyline(latlngs);
var map = new L.Map('map', {layers: [cloudmade]});
var group = new L.LayerGroup();
map.fitBounds(new L.LatLngBounds(latlngs));
@ -43,12 +46,12 @@
var circle = new L.Circle(circleLocation, 500000, circleOptions),
circleMarker = new L.CircleMarker(circleLocation, {fillColor: 'blue', fillOpacity: 1, stroke: false});
map.addLayer(circle).addLayer(circleMarker);
group.addLayer(circle).addLayer(circleMarker);
circle.bindPopup('I am a circle');
circleMarker.bindPopup('I am a circle marker');
map.addLayer(path);
group.addLayer(path);
path.bindPopup('I am a polyline');
var p1 = latlngs[0],
@ -77,9 +80,11 @@
fillColor: "#333",
color: 'green'
});
map.addLayer(polygon);
group.addLayer(polygon);
polygon.bindPopup('I am a polygon');
map.addLayer(group);
</script>