]> git.openstreetmap.org Git - rails.git/commitdiff
Move zoomPrecision function to the OSM namespace
authorTom Hughes <tom@compton.nu>
Thu, 27 Feb 2014 18:15:54 +0000 (18:15 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 27 Feb 2014 18:15:54 +0000 (18:15 +0000)
app/assets/javascripts/application.js
app/assets/javascripts/index.js
app/assets/javascripts/index/export.js
app/assets/javascripts/leaflet.map.js.erb
app/assets/javascripts/osm.js.erb
app/assets/javascripts/user.js

index 5d18f1da295dc947780707dbb967269e372e8154..75b48ac8715362aaa4fdb8dfd48735f4deeb4386 100644 (file)
 
 var querystring = require('querystring-component');
 
-function zoomPrecision(zoom) {
-    return Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
-}
-
 function remoteEditHandler(bbox, object) {
   var loaded = false,
       query = {
index 55e612f17668f6e3da055b2fdcf003b3a03c9285..4a9abc4dc0f78fe5fbb602f3d938a4cf2ff9b737 100644 (file)
@@ -333,7 +333,7 @@ $(document).ready(function () {
 
   $(".describe_location").on("click", function(e) {
     e.preventDefault();
-    var precision = zoomPrecision(map.getZoom());
+    var precision = OSM.zoomPrecision(map.getZoom());
     OSM.router.route("/search?query=" + encodeURIComponent(
       map.getCenter().lat.toFixed(precision) + "," +
       map.getCenter().lng.toFixed(precision)));
index fd658c53236922e1125ce55cdc6af2901acd8651..6e6867e5b5a15f5139f8b7ac5cac1d3ea3fa7af4 100644 (file)
@@ -36,7 +36,7 @@ OSM.Export = function(map) {
   }
 
   function setBounds(bounds) {
-    var precision = zoomPrecision(map.getZoom());
+    var precision = OSM.zoomPrecision(map.getZoom());
     $("#minlon").val(bounds.getWest().toFixed(precision));
     $("#minlat").val(bounds.getSouth().toFixed(precision));
     $("#maxlon").val(bounds.getEast().toFixed(precision));
index 7ae330d9bfcd50b7b1c0819fd15f6256222ef753..35370ae996108be6058ecc5b8cb8f8149d53bf49 100644 (file)
@@ -91,7 +91,7 @@ L.OSM.Map = L.Map.extend({
   },
 
   getUrl: function(marker) {
-    var precision = zoomPrecision(this.getZoom()),
+    var precision = OSM.zoomPrecision(this.getZoom()),
         params = {};
 
     if (marker && this.hasLayer(marker)) {
index 922bd2639d031fe93135d7c586c0a270df1a3bfc..382e32bdfde5d2285b065a685378bb796514eeb5 100644 (file)
@@ -153,7 +153,7 @@ OSM = {
     center = center.wrap();
     layers = layers.replace('M', '');
 
-    var precision = zoomPrecision(zoom),
+    var precision = OSM.zoomPrecision(zoom),
       hash = '#map=' + zoom +
         '/' + center.lat.toFixed(precision) +
         '/' + center.lng.toFixed(precision);
@@ -163,5 +163,9 @@ OSM = {
     }
 
     return hash;
+  },
+
+  zoomPrecision: function (zoom) {
+    return Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
   }
 };
index 6a0d38dd5d9dcd9ccce4ff4d34637bec30d38b3d..fb4aa030036e4b145028785a35a9b12f9f45b60f 100644 (file)
@@ -36,7 +36,7 @@ $(document).ready(function () {
     map.on("click", function (e) {
       if ($('#updatehome').is(':checked')) {
         var zoom = map.getZoom(),
-            precision = zoomPrecision(zoom),
+            precision = OSM.zoomPrecision(zoom),
             location = e.latlng.wrap();
 
         $('#homerow').removeClass();