merge reverse zoom TileLayer option from Majiir

This commit is contained in:
mourner 2012-02-03 12:41:18 +02:00
commit 8088be451e
2 changed files with 9 additions and 3 deletions

View File

@ -33,6 +33,7 @@ Leaflet Changelog
* Added `TileLayer` `continuousWorld` option to disable tile coordinates checking/wrapping.
* Added `TileLayer` `tileunload` event fired when tile gets removed after panning (by [@CodeJosch](https://github.com/CodeJosch)). [#256](https://github.com/CloudMade/Leaflet/pull/256)
* Added `TileLayer` `zoomOffset` option useful for non-256px tiles (by [@msaspence](https://github.com/msaspence)).
* Added `TileLayer` `zoomReverse` option to reverse zoom numbering (by [@Majiir](https://github.com/Majiir)). [#406](https://github.com/CloudMade/Leaflet/pull/406)
* Added `TileLayer.Canvas` `redraw` method (by [@mortenbekditlevsen](https://github.com/mortenbekditlevsen)). [#459](https://github.com/CloudMade/Leaflet/pull/459)
* Added `Polyline` `closestLayerPoint` method that's can be useful for interaction features (by [@anru](https://github.com/anru)). [#186](https://github.com/CloudMade/Leaflet/pull/186)
* Added `setLatLngs` method to `MultiPolyline` and `MultiPolygon` (by [@anru](https://github.com/anru)). [#194](https://github.com/CloudMade/Leaflet/pull/194)

View File

@ -17,7 +17,7 @@ L.TileLayer = L.Class.extend({
continuousWorld: false,
noWrap: false,
zoomOffset: 0,
reuseTiles: false,
zoomReverse: false,
unloadInvisibleTiles: L.Browser.mobile,
updateWhenIdle: L.Browser.mobile
@ -218,7 +218,7 @@ L.TileLayer = L.Class.extend({
var tilePos = this._getTilePos(tilePoint),
zoom = this._map.getZoom(),
key = tilePoint.x + ':' + tilePoint.y,
tileLimit = Math.pow(2, (zoom + this.options.zoomOffset));
tileLimit = Math.pow(2, this._getOffsetZoom(zoom));
// wrap tile coordinates
if (!this.options.continuousWorld) {
@ -250,6 +250,11 @@ L.TileLayer = L.Class.extend({
container.appendChild(tile);
},
_getOffsetZoom: function(zoom) {
zoom = this.options.zoomReverse ? this.options.maxZoom - zoom : zoom;
return zoom + this.options.zoomOffset;
},
_getTilePos: function (tilePoint) {
var origin = this._map.getPixelOrigin(),
tileSize = this.options.tileSize;
@ -265,7 +270,7 @@ L.TileLayer = L.Class.extend({
return L.Util.template(this._url, L.Util.extend({
s: s,
z: zoom + this.options.zoomOffset,
z: this._getOffsetZoom(zoom),
x: tilePoint.x,
y: tilePoint.y
}, this._urlParams));