diff --git a/app/static/css/map.css b/app/static/css/map.css index eb42ff5..46adeb4 100644 --- a/app/static/css/map.css +++ b/app/static/css/map.css @@ -1,4 +1,9 @@ -#mapid { +.large-map { min-height: 400px; height: 600px; -} \ No newline at end of file +} + +.small-map { + min-height: 150px; + height: 250px; +} diff --git a/app/static/js/map.js b/app/static/js/map.js index 20f68f4..18344df 100644 --- a/app/static/js/map.js +++ b/app/static/js/map.js @@ -1,11 +1,11 @@ -var map = L.map('mapid').setView([ - 51.0231119, 3.7102741 -], 14); +var map = L.map('mapid'); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); +let base_request_uri = "https://photon.komoot.de/api/?limit=1&q="; + function performRequest(url, location, success_callback) { var request = new XMLHttpRequest(); request.open('GET', url, true); @@ -52,6 +52,10 @@ let callback = function OSMCallBack(location, data) { marker.on('mouseout', function(env) { marker.closePopup(); }); + + if (location.center) { + map.setView([lat, lon], 14); + } } else { console.log(`Location ${JSON.stringify(location, null, 2)} returned no features, are you sure this is a valid address?`); } @@ -59,7 +63,7 @@ let callback = function OSMCallBack(location, data) { function loadmap(locations) { for (let loc of locations) { - let request_uri = "https://photon.komoot.de/api/?limit=1&q=" + loc.address; + let request_uri = base_request_uri + loc.address; performRequest(request_uri, loc, callback); } } diff --git a/app/templates/location.html b/app/templates/location.html index 2ac5081..3175d32 100644 --- a/app/templates/location.html +++ b/app/templates/location.html @@ -5,12 +5,19 @@ {% block container %}