From a2c2342000aea4efa5140afa89e4ed66dd466100 Mon Sep 17 00:00:00 2001 From: lltommy Date: Tue, 16 Jun 2020 12:43:08 +0200 Subject: starting to include a map --- bh20simplewebuploader/main.py | 11 ++++++-- bh20simplewebuploader/static/main.js | 34 +++++++++++++++++++++++ bh20simplewebuploader/templates/map.html | 46 ++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 bh20simplewebuploader/templates/map.html diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 840070d..40046c8 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -459,6 +459,13 @@ def about_page(): buf = get_html_body('doc/web/about.html') return render_template('about.html',menu='ABOUT',embed=buf) +## +@app.route('/map') +def map_page(): + return render_template('map.html',menu='DEMO') + + + ## Dynamic API functions starting here ## This is quick and dirty for now, just to get something out and demonstrate the queries ## Feel free to rename the functions/endpoints, feel free to process result so we get nicer JSON @@ -522,10 +529,10 @@ def getCountByGPS(): payload = {'query': query, 'format': 'json'} r = requests.get(baseURL, params=payload) result = r.json()['results']['bindings'] - return jsonify([{'Fasta Count': x['fastaCount']['value'], + return jsonify([{'count': x['fastaCount']['value'], 'Location': x['location']['value'], 'LocationLabel': x['location_label']['value'], - 'GPS' :x['GPS']['value']} for x in result]) + 'GPS' :x['GPS']['value'][6:-1]} for x in result]) @app.route('/api/getSEQCountbytech', methods=['GET']) 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: '© OpenStreetMap contributors' +}).addTo(mymap); + +fetch(scriptRoot + "api/getCountByGPS") + .then(response => { + console.log(response) + return response.json(); + }) + .then(data => { + + for (var i=0; i + + {% include 'header.html' %} + + + {% include 'banner.html' %} + {% include 'menu.html' %} +
+ + {% include 'footer.html' %} + + + + + + + + + + + + + + -- cgit v1.2.3