Skip to content

Commit

Permalink
Naïve fix for non-integer zoomlevels in CRS.scale; interpolation resu…
Browse files Browse the repository at this point in the history
…lts in discontinuities
  • Loading branch information
perliedman authored and semone committed Aug 29, 2015
1 parent eea0025 commit aa398e1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/proj4leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,21 @@
},

scale: function(zoom) {
return this._scales[zoom];
var iZoom = Math.floor(zoom),
baseScale,
nextScale,
scaleDiff,
zDiff;
if (zoom === iZoom) {
return this._scales[zoom];
} else {
// Non-integer zoom, interpolate
baseScale = this._scales[iZoom];
nextScale = this._scales[iZoom + 1];
scaleDiff = nextScale - baseScale;
zDiff = (zoom - iZoom);
return baseScale + scaleDiff * Math.pow(zDiff, nextScale / baseScale);
}
},
});

Expand Down

0 comments on commit aa398e1

Please sign in to comment.