aboutsummaryrefslogtreecommitdiff
path: root/bh20simplewebuploader/static/main.js
diff options
context:
space:
mode:
authorLLTommy2020-06-17 19:22:24 +0200
committerGitHub2020-06-17 19:22:24 +0200
commitae6b95d8e3053e9a446702d77e7ad56a321acda7 (patch)
treeb7fa6afa5c260ef80f84d90e0d7aac891f34db40 /bh20simplewebuploader/static/main.js
parenta2c2342000aea4efa5140afa89e4ed66dd466100 (diff)
parenta80646c6d6f2d768f63db2545f7e1542ea290f77 (diff)
downloadbh20-seq-resource-ae6b95d8e3053e9a446702d77e7ad56a321acda7.tar.gz
bh20-seq-resource-ae6b95d8e3053e9a446702d77e7ad56a321acda7.tar.lz
bh20-seq-resource-ae6b95d8e3053e9a446702d77e7ad56a321acda7.zip
Merge pull request #83 from BonfaceKilz/feature/display-content-sequences
Feature/display fasta count on a map
Diffstat (limited to 'bh20simplewebuploader/static/main.js')
-rw-r--r--bh20simplewebuploader/static/main.js30
1 files changed, 29 insertions, 1 deletions
diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js
index efefe70..f2e5d99 100644
--- a/bh20simplewebuploader/static/main.js
+++ b/bh20simplewebuploader/static/main.js
@@ -13,15 +13,43 @@ function myFunction() {
}
}
+let map = L.map( 'map', {
+ center: [37.0902, -95.7129], // Default to U.S.A
+ minZoom: 3,
+ zoom: 0
+});
+L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
+ attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
+ 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 => {
- document.getElementById("json").textContent = JSON.stringify(data, undefined, 2);
+ 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("<b>" + label + "</b><br/>" + "FastaCount: " +fastaCount);
+ markers.addLayer(marker)
+ }}
+ }
+ // Reload the map
+ map.invalidateSize();
});
document.getElementById("results").classList.add("invisible");
document.getElementById("loader").classList.remove("invisible");