var oldL = window.L,
L = {};
-L.version = '0.7.1';
+L.version = '0.7.2';
// define Leaflet for Node module pattern loaders, including Browserify
if (typeof module === 'object' && typeof module.exports === 'object') {
attribution: '',
zoomOffset: 0,
opacity: 1,
- /* (undefined works too)
+ /*
+ maxNativeZoom: null,
zIndex: null,
tms: false,
continuousWorld: false,
// create a container div for tiles
this._initContainer();
- // create an image to clone for tiles
- this._createTileProto();
-
// set up events
map.on({
'viewreset': this._reset,
if (!this._map) { return; }
- var bounds = this._map.getPixelBounds(),
- zoom = this._map.getZoom(),
- tileSize = this.options.tileSize;
+ var map = this._map,
+ bounds = map.getPixelBounds(),
+ zoom = map.getZoom(),
+ tileSize = this._getTileSize();
if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {
return;
zoom = options.maxZoom - zoom;
}
- return zoom + options.zoomOffset;
+ zoom += options.zoomOffset;
+
+ return options.maxNativeZoom ? Math.min(zoom, options.maxNativeZoom) : zoom;
},
_getTilePos: function (tilePoint) {
var origin = this._map.getPixelOrigin(),
- tileSize = this.options.tileSize;
+ tileSize = this._getTileSize();
return tilePoint.multiplyBy(tileSize).subtract(origin);
},
_getWrapTileNum: function () {
var crs = this._map.options.crs,
size = crs.getSize(this._map.getZoom());
- return size.divideBy(this.options.tileSize);
+ return size.divideBy(this._getTileSize())._floor();
},
_adjustTilePoint: function (tilePoint) {
return this.options.subdomains[index];
},
- _createTileProto: function () {
- var img = this._tileImg = L.DomUtil.create('img', 'leaflet-tile');
- img.style.width = img.style.height = this.options.tileSize + 'px';
- img.galleryimg = 'no';
- },
-
_getTile: function () {
if (this.options.reuseTiles && this._unusedTiles.length > 0) {
var tile = this._unusedTiles.pop();
_resetTile: function (/*tile*/) {},
_createTile: function () {
- var tile = this._tileImg.cloneNode(false);
+ var tile = L.DomUtil.create('img', 'leaflet-tile');
+ tile.style.width = tile.style.height = this._getTileSize() + 'px';
+ tile.galleryimg = 'no';
+
tile.onselectstart = tile.onmousemove = L.Util.falseFn;
if (L.Browser.ielt9 && this.options.opacity !== undefined) {
this.drawTile(tile, tile._tilePoint, this._map._zoom);
},
- _createTileProto: function () {
- var proto = this._canvasProto = L.DomUtil.create('canvas', 'leaflet-tile');
- proto.width = proto.height = this.options.tileSize;
- },
-
_createTile: function () {
- var tile = this._canvasProto.cloneNode(false);
+ var tile = L.DomUtil.create('canvas', 'leaflet-tile');
+ tile.width = tile.height = this.options.tileSize;
tile.onselectstart = tile.onmousemove = L.Util.falseFn;
return tile;
},
},
getMousePosition: function (e, container) {
- var body = document.body,
- docEl = document.documentElement,
- //gecko makes scrollLeft more negative as you scroll in rtl, other browsers don't
- //ref: https://code.google.com/p/closure-library/source/browse/closure/goog/style/bidi.js
- x = L.DomUtil.documentIsLtr() ?
- (e.pageX ? e.pageX - body.scrollLeft - docEl.scrollLeft : e.clientX) :
- (L.Browser.gecko ? e.pageX - body.scrollLeft - docEl.scrollLeft :
- e.pageX ? e.pageX - body.scrollLeft + docEl.scrollLeft : e.clientX),
- y = e.pageY ? e.pageY - body.scrollTop - docEl.scrollTop: e.clientY,
- pos = new L.Point(x, y);
-
if (!container) {
- return pos;
+ return new L.Point(e.clientX, e.clientY);
}
- var rect = container.getBoundingClientRect(),
- left = rect.left - container.clientLeft,
- top = rect.top - container.clientTop;
+ var rect = container.getBoundingClientRect();
- return pos._subtract(new L.Point(left, top));
+ return new L.Point(
+ e.clientX - rect.left - container.clientLeft,
+ e.clientY - rect.top - container.clientTop);
},
getWheelDelta: function (e) {