From 967e1d56a81c184d3dc8d265dec13852eb8c90a6 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 17 Jun 2020 03:13:53 +0300 Subject: Move leaflet CSS to the head section --- bh20simplewebuploader/templates/header.html | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bh20simplewebuploader/templates/header.html') diff --git a/bh20simplewebuploader/templates/header.html b/bh20simplewebuploader/templates/header.html index 5c0e1a0..adb0fd8 100644 --- a/bh20simplewebuploader/templates/header.html +++ b/bh20simplewebuploader/templates/header.html @@ -7,4 +7,10 @@ {% if blog %} {% endif %} + + -- cgit v1.2.3 From e8dab2bef5d09f0aee6f1b6e43bcce24ca42ddcb Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 17 Jun 2020 15:51:14 +0300 Subject: Move js script to bottom of page Methods associated with map need to be created after the div container --- bh20simplewebuploader/templates/footer.html | 1 + bh20simplewebuploader/templates/header.html | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'bh20simplewebuploader/templates/header.html') diff --git a/bh20simplewebuploader/templates/footer.html b/bh20simplewebuploader/templates/footer.html index 7366507..9326b1e 100644 --- a/bh20simplewebuploader/templates/footer.html +++ b/bh20simplewebuploader/templates/footer.html @@ -40,3 +40,4 @@ + diff --git a/bh20simplewebuploader/templates/header.html b/bh20simplewebuploader/templates/header.html index adb0fd8..35882d7 100644 --- a/bh20simplewebuploader/templates/header.html +++ b/bh20simplewebuploader/templates/header.html @@ -3,7 +3,6 @@ COVID-19 PubSeq: Public SARS-CoV-2 Sequence Resource - {% if blog %} {% endif %} -- cgit v1.2.3 From a80646c6d6f2d768f63db2545f7e1542ea290f77 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 17 Jun 2020 18:54:58 +0300 Subject: Add cluster marker group When markers are close together, lump them together. Also, it provides a convenient method of remove markers when loading other GPS co-ordinates --- bh20simplewebuploader/static/main.js | 18 +++++++++++++++++- bh20simplewebuploader/templates/header.html | 12 ++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'bh20simplewebuploader/templates/header.html') diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js index 0556fb7..149eb3c 100644 --- a/bh20simplewebuploader/static/main.js +++ b/bh20simplewebuploader/static/main.js @@ -23,15 +23,31 @@ L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { subdomains: ['a','b','c'] }).addTo( map ); +let markers = L.markerClusterGroup().addTo(map) + + function fetchAPI(apiEndPoint) { fetch(scriptRoot + apiEndPoint) .then(response => { return response.json(); }) .then(data => { - console.log(data); + markers.clearLayers(); document.getElementById("results").classList.remove("invisible"); document.getElementById("loader").classList.add("invisible"); + if (!(apiEndPoint === "/api/getAllaccessions")) { + for (let i = 0; i < data.length; i++) { + let {"Fasta Count": fastaCount, GPS, LocationLabel: label } = data[i]; + let coordinates = GPS.match(/Point\((-?[0-9]+(?:.(?:[0-9]+)?)?) (-?[0-9]+(?:.(?:[0-9]+)?)?)\)/); + if (!(coordinates == null)) { + let lat, lon; + [lon, lat] = coordinates.slice(1, 3).map(parseFloat); + let point = L.point() + let marker = L.marker([lat, lon]); + marker.bindPopup("" + label + "
" + "FastaCount: " +fastaCount); + markers.addLayer(marker) + }} + } // Reload the map map.invalidateSize(); }); diff --git a/bh20simplewebuploader/templates/header.html b/bh20simplewebuploader/templates/header.html index 35882d7..0ac5157 100644 --- a/bh20simplewebuploader/templates/header.html +++ b/bh20simplewebuploader/templates/header.html @@ -9,7 +9,19 @@ + + + + + + -- cgit v1.2.3