From 35b35453f92ee0be2fc21faef43845fe011a8098 Mon Sep 17 00:00:00 2001 From: Mourner Date: Fri, 10 Jun 2011 16:25:07 +0300 Subject: [PATCH] update basic example using FeatureGroup --- debug/map/map.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/debug/map/map.html b/debug/map/map.html index 983b7133..88bdd5b0 100644 --- a/debug/map/map.html +++ b/debug/map/map.html @@ -24,12 +24,7 @@ var map = new L.Map('map', {center: latlng, zoom: 15, layers: [cloudmade]}); - function createMarker(latlng) { - var marker = new L.Marker(latlng); - map.addLayer(marker); - marker.bindPopup("

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.

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque.

"); - return marker; - } + var markers = new L.FeatureGroup(); function populate() { var bounds = map.getBounds(), @@ -42,11 +37,16 @@ var latlng = new L.LatLng( southWest.lat + latSpan * Math.random(), southWest.lng + lngSpan * Math.random()); - createMarker(latlng); + + markers.addLayer(new L.Marker(latlng)); } return false; }; + + markers.bindPopup("

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.

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque.

"); + + map.addLayer(markers); populate(); L.DomUtil.get('populate').onclick = populate;