update basic example using FeatureGroup
This commit is contained in:
parent
5c2e3a511f
commit
35b35453f9
@ -24,12 +24,7 @@
|
|||||||
|
|
||||||
var map = new L.Map('map', {center: latlng, zoom: 15, layers: [cloudmade]});
|
var map = new L.Map('map', {center: latlng, zoom: 15, layers: [cloudmade]});
|
||||||
|
|
||||||
function createMarker(latlng) {
|
var markers = new L.FeatureGroup();
|
||||||
var marker = new L.Marker(latlng);
|
|
||||||
map.addLayer(marker);
|
|
||||||
marker.bindPopup("<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p><p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque.</p>");
|
|
||||||
return marker;
|
|
||||||
}
|
|
||||||
|
|
||||||
function populate() {
|
function populate() {
|
||||||
var bounds = map.getBounds(),
|
var bounds = map.getBounds(),
|
||||||
@ -42,12 +37,17 @@
|
|||||||
var latlng = new L.LatLng(
|
var latlng = new L.LatLng(
|
||||||
southWest.lat + latSpan * Math.random(),
|
southWest.lat + latSpan * Math.random(),
|
||||||
southWest.lng + lngSpan * Math.random());
|
southWest.lng + lngSpan * Math.random());
|
||||||
createMarker(latlng);
|
|
||||||
|
markers.addLayer(new L.Marker(latlng));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
markers.bindPopup("<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p><p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque.</p>");
|
||||||
|
|
||||||
|
map.addLayer(markers);
|
||||||
|
|
||||||
populate();
|
populate();
|
||||||
L.DomUtil.get('populate').onclick = populate;
|
L.DomUtil.get('populate').onclick = populate;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user