diff --git a/html/js/webpage.js b/html/js/webpage.js index dd58825..5641cf5 100644 --- a/html/js/webpage.js +++ b/html/js/webpage.js @@ -55,6 +55,7 @@ function showMap(){ attribution: '© OpenStreetMap contributors' }).addTo(map); + map.setView([0, 0], 1); } function clearMap() { @@ -79,15 +80,14 @@ function get_random_colour() { } function plotMarkers(bounds, markArray){ - showMap(); - map.fitBounds(bounds); + map.flyToBounds(bounds, {padding:[50,50]}) clearMap(); // loop over each marker and add to map marksLayerGroup = L.layerGroup(); markArray.forEach(function(mark){ - marksLayerGroup.addLayer(L.marker([mark[1],mark[2]]).bindPopup(mark[0])).addTo(map); + marker = new L.marker([mark[1],mark[2]]).bindPopup(mark[0]).addTo(map) }); } @@ -115,13 +115,9 @@ ws.onmessage = function (event) { // Enable submit button $('#submit').attr("disabled",false); - $('#map_placeholder').hide(); // Map handling functionality if(edata.hasOwnProperty('markers')){ - $('#map_placeholder').show(); - $('#map_placeholder').html("").append('
'); - plotMarkers(bounds,markers); } @@ -133,6 +129,7 @@ ws.onmessage = function (event) { if(name === 'init'){ // stylise field val into field: val $('#processing').hide(); + showMap(); } // Output table data diff --git a/html/setlistfm-mapper.html b/html/setlistfm-mapper.html index 55af49a..3aa7845 100644 --- a/html/setlistfm-mapper.html +++ b/html/setlistfm-mapper.html @@ -41,13 +41,12 @@

Enter username

Connecting...

+
+
+
- -
- -