diff options
author | Christopher Baines <cb15g11@soton.ac.uk> | 2014-09-17 15:06:15 +0100 |
---|---|---|
committer | Christopher Baines <cb15g11@soton.ac.uk> | 2014-09-17 15:06:15 +0100 |
commit | 9373af8df20df1e125e72c96ec18b5fc67c73405 (patch) | |
tree | 84f26cc1e604bc08adec80a8e14a0549536c59ce /examples/cycleparkingheatmap.html | |
parent | 541329d02b32c0ce547d62e5b7b7f42ea9fd2a40 (diff) | |
download | leaflet-soton-9373af8df20df1e125e72c96ec18b5fc67c73405.tar leaflet-soton-9373af8df20df1e125e72c96ec18b5fc67c73405.tar.gz |
Less globals in examples
Fix a problem highlighted by this in the vending manchines layer.
Diffstat (limited to 'examples/cycleparkingheatmap.html')
-rw-r--r-- | examples/cycleparkingheatmap.html | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/examples/cycleparkingheatmap.html b/examples/cycleparkingheatmap.html index 17b5116..24e6fd1 100644 --- a/examples/cycleparkingheatmap.html +++ b/examples/cycleparkingheatmap.html @@ -31,46 +31,48 @@ LS.imagePath = '../resources/images/'; LS.dataPath = '../data.json'; - var map = LS.map('map', { - indoor: false, - }); + (function() { + var map = LS.map('map', { + indoor: false, + }); - LS.getData(function(data) { - var heatmapData = []; + LS.getData(function(data) { + var heatmapData = []; - console.log(data); + console.log(data); - data.bicycleParking.features.forEach(function(feature) { - var lat, - lon; + data.bicycleParking.features.forEach(function(feature) { + var lat, + lon; - if (feature.geometry.type === "Point") { - lat = feature.geometry.coordinates[1]; - lon = feature.geometry.coordinates[0]; - } else if (feature.geometry.type === "Polygon") { - lat = feature.geometry.coordinates[0][0][1]; - lon = feature.geometry.coordinates[0][0][0]; - } + if (feature.geometry.type === "Point") { + lat = feature.geometry.coordinates[1]; + lon = feature.geometry.coordinates[0]; + } else if (feature.geometry.type === "Polygon") { + lat = feature.geometry.coordinates[0][0][1]; + lon = feature.geometry.coordinates[0][0][0]; + } - if ("capacity" in feature.properties) { - for (var i=0; i<feature.properties.capacity; i++) { + if ("capacity" in feature.properties) { + for (var i=0; i<feature.properties.capacity; i++) { + heatmapData.push([lat, lon]); + } + } else { heatmapData.push([lat, lon]); } - } else { - heatmapData.push([lat, lon]); - } - }); + }); - var heat = L.heatLayer(heatmapData, { - radius: 20, - blur: 5, - gradient: { - 0.4: 'green', - 0.65: 'lime', - 1: 'green' - } - }).addTo(map); - }); + var heat = L.heatLayer(heatmapData, { + radius: 20, + blur: 5, + gradient: { + 0.4: 'green', + 0.65: 'lime', + 1: 'green' + } + }).addTo(map); + }); + })(); </script> </body> </html> |