From c69df0c5790ca5f92ebbdfdc00767109442479ff Mon Sep 17 00:00:00 2001 From: Lou Huang Date: Tue, 20 Sep 2016 16:11:57 -0400 Subject: [PATCH] Support leaflet v1+ fractional zooms Signed-off-by: Johannes Rudolph --- src/leaflet-hash.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/leaflet-hash.js b/src/leaflet-hash.js index cfb0a71..56b51af 100644 --- a/src/leaflet-hash.js +++ b/src/leaflet-hash.js @@ -19,7 +19,7 @@ } var args = hash.split("/"); if (args.length == 3) { - var zoom = parseInt(args[0], 10), + var zoom = (L.version >= '1.0.0') ? parseFloat(args[0]) : parseInt(args[0], 10), lat = parseFloat(args[1]), lon = parseFloat(args[2]); if (isNaN(zoom) || isNaN(lat) || isNaN(lon)) { @@ -40,7 +40,7 @@ zoom = map.getZoom(), precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)); - return "#" + [zoom, + return "#" + [(L.version >= '1.0.0') ? zoom.toFixed(precision) : zoom, center.lat.toFixed(precision), center.lng.toFixed(precision) ].join("/");