Skip to content

Commit

Permalink
adjust styling zoom based on latitude, close #192
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Mar 27, 2014
1 parent 771d120 commit 71d36c3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions js/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,18 @@ util.extend(Map.prototype, {
},

_updateStyle: function() {
if (this.style) {
this.style.recalculate(this.transform.zoom);
}
if (!this.style) return;

// adjust zoom value based on latitude to compensate for Mercator projection distortion;
// start increasing adjustment from 0% at zoom 7 to 100% at zoom 9

var zoom = this.transform.zoom,
scale = this.transform.scaleZoom(1 / Math.cos(this.transform.center.lat * Math.PI / 180)),
minAdjustZoom = 6,
maxAdjustZoom = 9,
multiplier = Math.min(Math.max(zoom - maxAdjustZoom, 0) / (maxAdjustZoom - minAdjustZoom), 1);

this.style.recalculate(zoom + scale * multiplier);
},

_updateBuckets: function() {
Expand Down

0 comments on commit 71d36c3

Please sign in to comment.