Browse Source

Fix zoom calculation result

Steffen Kühne 5 years ago
parent
commit
571b93297c
3 changed files with 5 additions and 5 deletions
  1. 2 1
      convert.js
  2. 2 3
      index.html
  3. 1 1
      locations.js

+ 2 - 1
convert.js

@@ -59,6 +59,7 @@ function convertData(data) {
     }
 
     mapFocus = calculateMapFocus(latMin, latMax, longMin, longMax);
+    console.log(mapFocus);
 
     fileContent += 'var ' + locationsVariable + ' = ' + JSON.stringify(convertedData) + ';\n';
     fileContent += 'var ' + mapVariable + ' = ' + JSON.stringify(mapFocus) + ';';
@@ -87,7 +88,7 @@ function calculateMapFocus(latMin, latMax, longMin, longMax) {
     return {
         lat : ((latMax - latMin) / 2) + latMin,
         long: ((longMax - longMin) / 2) + longMin,
-        zoom: Math.sqrt(Math.pow(latMax - latMin, 2) + Math.pow(longMax - longMin, 2)) / zoomFactor
+        zoom: Math.round(Math.sqrt(Math.pow(latMax - latMin, 2) + Math.pow(longMax - longMin, 2)) / zoomFactor)
     };
 }
 

+ 2 - 3
index.html

@@ -33,9 +33,8 @@
 
     var map = L.map('map').setView([map.lat, map.long], map.zoom);
 
-    var tiles = L.tileLayer('http://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', {
-        attribution: '<a href="https://www.mapbox.com/about/maps/">Terms and Feedback</a>',
-        id: 'examples.map-20v6611k'
+    var tiles = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
+        attribution: '<a href="http://www.openstretmap.org/copyright">© OpenStreetMap-Mitwirkende</a>'
     }).addTo(map);
 
     var heat = L.heatLayer(locations, {radius: 15}).addTo(map);

File diff suppressed because it is too large
+ 1 - 1
locations.js