merge reverse zoom TileLayer option from Majiir
This commit is contained in:
commit
8088be451e
@ -33,6 +33,7 @@ Leaflet Changelog
|
|||||||
* Added `TileLayer` `continuousWorld` option to disable tile coordinates checking/wrapping.
|
* 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` `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` `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 `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 `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)
|
* Added `setLatLngs` method to `MultiPolyline` and `MultiPolygon` (by [@anru](https://github.com/anru)). [#194](https://github.com/CloudMade/Leaflet/pull/194)
|
||||||
|
@ -17,7 +17,7 @@ L.TileLayer = L.Class.extend({
|
|||||||
continuousWorld: false,
|
continuousWorld: false,
|
||||||
noWrap: false,
|
noWrap: false,
|
||||||
zoomOffset: 0,
|
zoomOffset: 0,
|
||||||
reuseTiles: false,
|
zoomReverse: false,
|
||||||
|
|
||||||
unloadInvisibleTiles: L.Browser.mobile,
|
unloadInvisibleTiles: L.Browser.mobile,
|
||||||
updateWhenIdle: L.Browser.mobile
|
updateWhenIdle: L.Browser.mobile
|
||||||
@ -218,7 +218,7 @@ L.TileLayer = L.Class.extend({
|
|||||||
var tilePos = this._getTilePos(tilePoint),
|
var tilePos = this._getTilePos(tilePoint),
|
||||||
zoom = this._map.getZoom(),
|
zoom = this._map.getZoom(),
|
||||||
key = tilePoint.x + ':' + tilePoint.y,
|
key = tilePoint.x + ':' + tilePoint.y,
|
||||||
tileLimit = Math.pow(2, (zoom + this.options.zoomOffset));
|
tileLimit = Math.pow(2, this._getOffsetZoom(zoom));
|
||||||
|
|
||||||
// wrap tile coordinates
|
// wrap tile coordinates
|
||||||
if (!this.options.continuousWorld) {
|
if (!this.options.continuousWorld) {
|
||||||
@ -250,6 +250,11 @@ L.TileLayer = L.Class.extend({
|
|||||||
container.appendChild(tile);
|
container.appendChild(tile);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getOffsetZoom: function(zoom) {
|
||||||
|
zoom = this.options.zoomReverse ? this.options.maxZoom - zoom : zoom;
|
||||||
|
return zoom + this.options.zoomOffset;
|
||||||
|
},
|
||||||
|
|
||||||
_getTilePos: function (tilePoint) {
|
_getTilePos: function (tilePoint) {
|
||||||
var origin = this._map.getPixelOrigin(),
|
var origin = this._map.getPixelOrigin(),
|
||||||
tileSize = this.options.tileSize;
|
tileSize = this.options.tileSize;
|
||||||
@ -265,7 +270,7 @@ L.TileLayer = L.Class.extend({
|
|||||||
|
|
||||||
return L.Util.template(this._url, L.Util.extend({
|
return L.Util.template(this._url, L.Util.extend({
|
||||||
s: s,
|
s: s,
|
||||||
z: zoom + this.options.zoomOffset,
|
z: this._getOffsetZoom(zoom),
|
||||||
x: tilePoint.x,
|
x: tilePoint.x,
|
||||||
y: tilePoint.y
|
y: tilePoint.y
|
||||||
}, this._urlParams));
|
}, this._urlParams));
|
||||||
|
Loading…
Reference in New Issue
Block a user