Update to Leaflet 0.7.2

This commit is contained in:
Tom Hughes 2014-03-04 15:53:40 +00:00
parent 0de7fdb4df
commit 1e45b8f521
2 changed files with 26 additions and 43 deletions

View file

@ -11,13 +11,13 @@ folder 'vendor/assets' do
end end
folder 'leaflet' do folder 'leaflet' do
file 'leaflet.js', 'http://cdn.leafletjs.com/leaflet-0.7.1/leaflet-src.js' file 'leaflet.js', 'http://cdn.leafletjs.com/leaflet-0.7.2/leaflet-src.js'
file 'leaflet.css', 'http://cdn.leafletjs.com/leaflet-0.7.1/leaflet.css' file 'leaflet.css', 'http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css'
[ 'layers.png', 'layers-2x.png', [ 'layers.png', 'layers-2x.png',
'marker-icon.png', 'marker-icon-2x.png', 'marker-icon.png', 'marker-icon-2x.png',
'marker-shadow.png' ].each do |image| 'marker-shadow.png' ].each do |image|
file "images/#{image}", "http://cdn.leafletjs.com/leaflet-0.7.1/images/#{image}" file "images/#{image}", "http://cdn.leafletjs.com/leaflet-0.7.2/images/#{image}"
end end
from 'git://github.com/kajic/leaflet-locationfilter.git' do from 'git://github.com/kajic/leaflet-locationfilter.git' do

View file

@ -7,7 +7,7 @@
var oldL = window.L, var oldL = window.L,
L = {}; L = {};
L.version = '0.7.1'; L.version = '0.7.2';
// define Leaflet for Node module pattern loaders, including Browserify // define Leaflet for Node module pattern loaders, including Browserify
if (typeof module === 'object' && typeof module.exports === 'object') { if (typeof module === 'object' && typeof module.exports === 'object') {
@ -2436,7 +2436,8 @@ L.TileLayer = L.Class.extend({
attribution: '', attribution: '',
zoomOffset: 0, zoomOffset: 0,
opacity: 1, opacity: 1,
/* (undefined works too) /*
maxNativeZoom: null,
zIndex: null, zIndex: null,
tms: false, tms: false,
continuousWorld: false, continuousWorld: false,
@ -2485,9 +2486,6 @@ L.TileLayer = L.Class.extend({
// create a container div for tiles // create a container div for tiles
this._initContainer(); this._initContainer();
// create an image to clone for tiles
this._createTileProto();
// set up events // set up events
map.on({ map.on({
'viewreset': this._reset, 'viewreset': this._reset,
@ -2707,9 +2705,10 @@ L.TileLayer = L.Class.extend({
if (!this._map) { return; } if (!this._map) { return; }
var bounds = this._map.getPixelBounds(), var map = this._map,
zoom = this._map.getZoom(), bounds = map.getPixelBounds(),
tileSize = this.options.tileSize; zoom = map.getZoom(),
tileSize = this._getTileSize();
if (zoom > this.options.maxZoom || zoom < this.options.minZoom) { if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {
return; return;
@ -2870,12 +2869,14 @@ L.TileLayer = L.Class.extend({
zoom = options.maxZoom - zoom; zoom = options.maxZoom - zoom;
} }
return zoom + options.zoomOffset; zoom += options.zoomOffset;
return options.maxNativeZoom ? Math.min(zoom, options.maxNativeZoom) : zoom;
}, },
_getTilePos: function (tilePoint) { _getTilePos: function (tilePoint) {
var origin = this._map.getPixelOrigin(), var origin = this._map.getPixelOrigin(),
tileSize = this.options.tileSize; tileSize = this._getTileSize();
return tilePoint.multiplyBy(tileSize).subtract(origin); return tilePoint.multiplyBy(tileSize).subtract(origin);
}, },
@ -2894,7 +2895,7 @@ L.TileLayer = L.Class.extend({
_getWrapTileNum: function () { _getWrapTileNum: function () {
var crs = this._map.options.crs, var crs = this._map.options.crs,
size = crs.getSize(this._map.getZoom()); size = crs.getSize(this._map.getZoom());
return size.divideBy(this.options.tileSize); return size.divideBy(this._getTileSize())._floor();
}, },
_adjustTilePoint: function (tilePoint) { _adjustTilePoint: function (tilePoint) {
@ -2918,12 +2919,6 @@ L.TileLayer = L.Class.extend({
return this.options.subdomains[index]; 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 () { _getTile: function () {
if (this.options.reuseTiles && this._unusedTiles.length > 0) { if (this.options.reuseTiles && this._unusedTiles.length > 0) {
var tile = this._unusedTiles.pop(); var tile = this._unusedTiles.pop();
@ -2937,7 +2932,10 @@ L.TileLayer = L.Class.extend({
_resetTile: function (/*tile*/) {}, _resetTile: function (/*tile*/) {},
_createTile: function () { _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; tile.onselectstart = tile.onmousemove = L.Util.falseFn;
if (L.Browser.ielt9 && this.options.opacity !== undefined) { 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); 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 () { _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; tile.onselectstart = tile.onmousemove = L.Util.falseFn;
return tile; return tile;
}, },
@ -6535,26 +6529,15 @@ L.DomEvent = {
}, },
getMousePosition: function (e, container) { 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) { if (!container) {
return pos; return new L.Point(e.clientX, e.clientY);
} }
var rect = container.getBoundingClientRect(), var rect = container.getBoundingClientRect();
left = rect.left - container.clientLeft,
top = rect.top - container.clientTop;
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) { getWheelDelta: function (e) {