aboutsummaryrefslogtreecommitdiff
path: root/bh20simplewebuploader/static
diff options
context:
space:
mode:
authorlltommy2020-06-16 12:43:08 +0200
committerlltommy2020-06-16 12:43:08 +0200
commita2c2342000aea4efa5140afa89e4ed66dd466100 (patch)
treeb8ca1d0c661da3fccb014be455a1e525bf67db5e /bh20simplewebuploader/static
parentaf09eb9bc73484f218303d2c492da3adb99441d6 (diff)
downloadbh20-seq-resource-a2c2342000aea4efa5140afa89e4ed66dd466100.tar.gz
bh20-seq-resource-a2c2342000aea4efa5140afa89e4ed66dd466100.tar.lz
bh20-seq-resource-a2c2342000aea4efa5140afa89e4ed66dd466100.zip
starting to include a map
Diffstat (limited to 'bh20simplewebuploader/static')
-rw-r--r--bh20simplewebuploader/static/main.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js
index 1d2bcba..efefe70 100644
--- a/bh20simplewebuploader/static/main.js
+++ b/bh20simplewebuploader/static/main.js
@@ -28,6 +28,7 @@ function fetchAPI(apiEndPoint) {
}
+// Copy from function above but now added as table instead of plain json
function fetchAPIV2(apiEndPoint) {
fetch(scriptRoot + apiEndPoint)
.then(response => {
@@ -218,3 +219,36 @@ function on_submit_button() {
return false;
}
}
+
+
+
+//
+
+function drawMap(){
+
+// initialize the map on the "map" div with a given center and zoom
+var mymap = L.map('mapid').setView([51.505, -0.09], 1);
+
+L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
+ attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
+}).addTo(mymap);
+
+fetch(scriptRoot + "api/getCountByGPS")
+ .then(response => {
+ console.log(response)
+ return response.json();
+ })
+ .then(data => {
+
+ for (var i=0; i<data.length;i++) {
+ gps=data[i]["GPS"].split(" ")
+ var circle = L.circle([gps[1], gps[0]], {
+ color: 'red',
+ fillColor: '#f03',
+ fillOpacity: 0.5,
+ radius: parseInt(data[i]["count"]) //not working for whatever reason
+ }).addTo(mymap);
+ }
+
+ });
+} \ No newline at end of file