diff --git a/examples-leaflet-plugins/example1/index.html b/examples-leaflet-plugins/example1/index.html index ef4aa25..0d30456 100644 --- a/examples-leaflet-plugins/example1/index.html +++ b/examples-leaflet-plugins/example1/index.html @@ -9,6 +9,8 @@ + + @@ -35,7 +37,7 @@

geolocation

- + diff --git a/examples-leaflet-plugins/example1/js/main.js b/examples-leaflet-plugins/example1/js/main.js index e910b96..7c527c9 100644 --- a/examples-leaflet-plugins/example1/js/main.js +++ b/examples-leaflet-plugins/example1/js/main.js @@ -16,10 +16,12 @@ var Stamen_TonerLite = L.tileLayer(basemapURL, { ext: 'png' }).addTo(map); +L.control.locate().addTo(map); + var url = 'https://gist.githubusercontent.com/rossbernet/739cfd731519c8b49dd063779adedbd7/raw/cb1ca853899e9833f02ca0bc272dee74937c5d0c/squaresPoly.geojson'; var jsondata; $.ajax(url).done(function(res) { jsondata = JSON.parse(res); - layer = L.geoJSON(jsondata).addTo(map) + layer = L.geoJSON(jsondata).addTo(map); }); diff --git a/examples-leaflet-plugins/example2/index.html b/examples-leaflet-plugins/example2/index.html index ecf3d71..ed9a191 100644 --- a/examples-leaflet-plugins/example2/index.html +++ b/examples-leaflet-plugins/example2/index.html @@ -32,6 +32,7 @@

geocoding

+ diff --git a/examples-leaflet-plugins/example2/js/main.js b/examples-leaflet-plugins/example2/js/main.js index 8975d12..950412b 100644 --- a/examples-leaflet-plugins/example2/js/main.js +++ b/examples-leaflet-plugins/example2/js/main.js @@ -23,5 +23,5 @@ var url = 'https://gist.githubusercontent.com/rossbernet/739cfd731519c8b49dd0637 var jsondata; $.ajax(url).done(function(res) { jsondata = JSON.parse(res); - layer = L.geoJSON(jsondata).addTo(map) + layer = L.geoJSON(jsondata).addTo(map); }); diff --git a/lab/lab1/js/draw.js b/lab/lab1/js/draw.js index 9fb7ccc..1f4ff55 100644 --- a/lab/lab1/js/draw.js +++ b/lab/lab1/js/draw.js @@ -71,6 +71,7 @@ Moving your mouse outside of the circle should remove the highlighting. // Global Variables var myRectangle; +var myRectangles=[]; // Initialize Leaflet Draw var drawControl = new L.Control.Draw({ @@ -90,4 +91,21 @@ map.on('draw:created', function (e) { var type = e.layerType; // The type of shape var layer = e.layer; // The Leaflet layer for the shape var id = L.stamp(layer); // The unique Leaflet ID for the layer + + //Task 2 ~ 4; + if (myRectangle) { + map.removeLayer(myRectangle); + $('#shapes').empty(); + } + myRectangle = layer; + map.addLayer(layer); + $('#shapes').append('

Current ID:'+id+'

'); + + // //Stretch goal: Task 5 + // myRectangles.push(layer); + // console.log(myRectangles); + // $('#shapes').append('

Current ID:'+id+'

'); + // map.addLayer(layer); + + });