From a49e9be9576c17b5042b73781c9eb96277abd3fe 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 --- leaflet-hash.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/leaflet-hash.js b/leaflet-hash.js index 70a1007..1fda6d2 100644 --- a/leaflet-hash.js +++ b/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("/");