- zoomPrecision: function(zoom) {
- return Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
+ zoomPrecision: function (zoom) {
+ var pixels = Math.pow(2, 8 + zoom);
+ var degrees = 180;
+ return Math.ceil(Math.log10(pixels / degrees));
+ },
+
+ cropLocation: function (latLng, zoom) {
+ const precision = OSM.zoomPrecision(zoom),
+ wrapped = latLng.wrap();
+ return [wrapped.lat, wrapped.lng].map(c => c.toFixed(precision));