X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/ba1268ead6a78ca0c8f2b3ae6f048fafc9852aff..2f6165e040dff4231922a4d631085b6591d3b746:/vendor/assets/leaflet/leaflet.js diff --git a/vendor/assets/leaflet/leaflet.js b/vendor/assets/leaflet/leaflet.js index 6928837f6..e40bfbfaf 100644 --- a/vendor/assets/leaflet/leaflet.js +++ b/vendor/assets/leaflet/leaflet.js @@ -7,7 +7,7 @@ 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') { @@ -2436,7 +2436,8 @@ L.TileLayer = L.Class.extend({ attribution: '', zoomOffset: 0, opacity: 1, - /* (undefined works too) + /* + maxNativeZoom: null, zIndex: null, tms: false, continuousWorld: false, @@ -2485,9 +2486,6 @@ L.TileLayer = L.Class.extend({ // 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, @@ -2707,9 +2705,10 @@ L.TileLayer = L.Class.extend({ 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; @@ -2870,12 +2869,14 @@ L.TileLayer = L.Class.extend({ 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); }, @@ -2894,7 +2895,7 @@ L.TileLayer = L.Class.extend({ _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) { @@ -2918,12 +2919,6 @@ L.TileLayer = L.Class.extend({ 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(); @@ -2937,7 +2932,10 @@ L.TileLayer = L.Class.extend({ _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) { @@ -3140,13 +3138,9 @@ L.TileLayer.Canvas = L.TileLayer.extend({ 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; }, @@ -6535,26 +6529,15 @@ L.DomEvent = { }, 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) {