summaryrefslogtreecommitdiff
path: root/examples/cycleparkingheatmap.html
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cycleparkingheatmap.html')
-rw-r--r--examples/cycleparkingheatmap.html76
1 files changed, 76 insertions, 0 deletions
diff --git a/examples/cycleparkingheatmap.html b/examples/cycleparkingheatmap.html
new file mode 100644
index 0000000..17b5116
--- /dev/null
+++ b/examples/cycleparkingheatmap.html
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Cycle Parking Heat Map</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
+
+ <link rel="stylesheet" href="../src/leaflet-soton.css" />
+
+ <link rel="stylesheet" href="../resources/leaflet/dist/leaflet.css" />
+
+ <style>
+ body {
+ padding: 0;
+ margin: 0;
+ }
+
+ html, body, #map {
+ height: 100%;
+ }
+ </style>
+</head>
+<body>
+ <div id="map"></div>
+
+ <script src="../resources/leaflet/dist/leaflet.js"></script>
+ <script src="../resources/leaflet-heat/dist/leaflet-heat.js"></script>
+
+ <script src="../src/leaflet-soton.js"></script>
+
+ <script type="text/javascript">
+ LS.imagePath = '../resources/images/';
+ LS.dataPath = '../data.json';
+
+ var map = LS.map('map', {
+ indoor: false,
+ });
+
+ LS.getData(function(data) {
+ var heatmapData = [];
+
+ console.log(data);
+
+ 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 ("capacity" in feature.properties) {
+ for (var i=0; i<feature.properties.capacity; i++) {
+ 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);
+ });
+ </script>
+</body>
+</html>