diff --git a/src/ui/hash.js b/src/ui/hash.js index 28e97dabfa6..37052c6bb3b 100644 --- a/src/ui/hash.js +++ b/src/ui/hash.js @@ -54,9 +54,11 @@ class Hash { getHashString(mapFeedback?: boolean) { const center = this._map.getCenter(), zoom = Math.round(this._map.getZoom() * 100) / 100, - precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)), - lng = Math.round(center.lng * Math.pow(10, precision)) / Math.pow(10, precision), - lat = Math.round(center.lat * Math.pow(10, precision)) / Math.pow(10, precision), + // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px + precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10), + m = Math.pow(10, precision), + lng = Math.round(center.lng * m) / m, + lat = Math.round(center.lat * m) / m, bearing = this._map.getBearing(), pitch = this._map.getPitch(); let hash = '';