]> git.openstreetmap.org Git - rails.git/blobdiff - vendor/assets/leaflet/leaflet.js
Update to Leaflet 0.7.2
[rails.git] / vendor / assets / leaflet / leaflet.js
index 6928837f6f10bda885ab24ef2570565f64170301..e40bfbfafdc09a82ee0b89c519f939a587a801ef 100644 (file)
@@ -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) {