changeset 18:eafb0bca76fc

Add trace of prior geodata
author Lewin Bormann <lbo@spheniscida.de>
date Wed, 02 Dec 2020 20:05:19 +0100
parents 94fe2c70b4b4
children 19910bc79239
files Rocket.toml assets/livemap.html
diffstat 2 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Rocket.toml	Wed Dec 02 19:52:57 2020 +0100
+++ b/Rocket.toml	Wed Dec 02 20:05:19 2020 +0100
@@ -2,10 +2,10 @@
 geohub = { url = "postgresql://lbo:pglbo@localhost/lbo" }
 
 [development]
-workers = 5
+workers = 8
 
 [production]
 log = "normal"
 address = "::1"
 port = 8000
-workers = 5
+workers = 8
--- a/assets/livemap.html	Wed Dec 02 19:52:57 2020 +0100
+++ b/assets/livemap.html	Wed Dec 02 20:05:19 2020 +0100
@@ -9,7 +9,8 @@
     <div id="mapid"> </div>
 
     <script>
-    var mymap = L.map('mapid').setView([50.77, 6.11], 13);
+    const initial = [50, 12];
+    var mymap = L.map('mapid').setView(initial, 13);
 
     var accessToken = 'pk.eyJ1IjoiZGVybWVzc2VyIiwiYSI6ImNraTdwZmUxZTE2OGgydW1oYTU5eW9qYm4ifQ.f9OxY_U78h6iefp-jN9-9w';
     L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
@@ -44,10 +45,19 @@
                 const features = response['geo']['features'];
                 const newLastID = response['last'];
                 const lastfeature = features[0];
-                const coords = lastfeature['geometry']['coordinates'];
+                // Backfill old circles.
+                if (features.length > 0) {
+                    for (i = 1; i < features.length; i++) {
+                        var coords = features[i]['geometry']['coordinates'];
+                        L.circle([coords[1], coords[0]], circleProps).addTo(mymap);
+                    }
+                }
+
+                var coords = lastfeature['geometry']['coordinates'];
 
                 console.log('Received update:', coords, 'last:', response);
                 setCurrentLocation(coords[1], coords[0]);
+                mymap.setView([coords[1], coords[0]], mymap.getZoom());
                 window.lastID = newLastID;
             }