Update to Leaflet 0.7.1

This commit is contained in:
Tom Hughes 2013-12-06 16:24:36 +00:00
parent e05adbb917
commit ba1268ead6
2 changed files with 47 additions and 52 deletions

View file

@ -7,7 +7,7 @@
var oldL = window.L,
L = {};
L.version = '0.7';
L.version = '0.7.1';
// define Leaflet for Node module pattern loaders, including Browserify
if (typeof module === 'object' && typeof module.exports === 'object') {
@ -134,21 +134,16 @@ L.Util = {
}
return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');
},
compileTemplate: function (str, data) {
// based on https://gist.github.com/padolsey/6008842
str = str.replace(/"/g, '\\\"');
str = str.replace(/\{ *([\w_]+) *\}/g, function (str, key) {
return '" + o["' + key + '"]' + (typeof data[key] === 'function' ? '(o)' : '') + ' + "';
});
// jshint evil: true
return new Function('o', 'return "' + str + '";');
},
template: function (str, data) {
var cache = L.Util._templateCache = L.Util._templateCache || {};
cache[str] = cache[str] || L.Util.compileTemplate(str, data);
return cache[str](data);
return str.replace(/\{ *([\w_]+) *\}/g, function (str, key) {
var value = data[key];
if (value === undefined) {
throw new Error('No value provided for variable ' + str);
} else if (typeof value === 'function') {
value = value(data);
}
return value;
});
},
isArray: Array.isArray || function (obj) {
@ -534,7 +529,7 @@ L.Mixin.Events.fire = L.Mixin.Events.fireEvent;
doc = document.documentElement,
ie3d = ie && ('transition' in doc.style),
webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()),
webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23,
gecko3d = 'MozPerspective' in doc.style,
opera3d = 'OTransition' in doc.style,
any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d) && !phantomjs;
@ -1070,11 +1065,6 @@ L.DomUtil = {
if (!disable3D && L.Browser.any3d) {
el.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(point);
// workaround for Android 2/3 stability (https://github.com/CloudMade/Leaflet/issues/69)
if (L.Browser.mobileWebkit3d) {
el.style.WebkitBackfaceVisibility = 'hidden';
}
} else {
el.style.left = point.x + 'px';
el.style.top = point.y + 'px';
@ -1770,6 +1760,8 @@ L.Map = L.Class.extend({
},
invalidateSize: function (options) {
if (!this._loaded) { return this; }
options = L.extend({
animate: false,
pan: true
@ -1779,8 +1771,6 @@ L.Map = L.Class.extend({
this._sizeChanged = true;
this._initialCenter = null;
if (!this._loaded) { return this; }
var newSize = this.getSize(),
oldCenter = oldSize.divideBy(2).round(),
newCenter = newSize.divideBy(2).round(),
@ -2446,8 +2436,7 @@ L.TileLayer = L.Class.extend({
attribution: '',
zoomOffset: 0,
opacity: 1,
/*
maxNativeZoom: null,
/* (undefined works too)
zIndex: null,
tms: false,
continuousWorld: false,
@ -2496,6 +2485,9 @@ 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,
@ -2715,10 +2707,9 @@ L.TileLayer = L.Class.extend({
if (!this._map) { return; }
var map = this._map,
bounds = map.getPixelBounds(),
zoom = map.getZoom(),
tileSize = this._getTileSize();
var bounds = this._map.getPixelBounds(),
zoom = this._map.getZoom(),
tileSize = this.options.tileSize;
if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {
return;
@ -2857,11 +2848,9 @@ L.TileLayer = L.Class.extend({
/*
Chrome 20 layouts much faster with top/left (verify with timeline, frames)
Android 4 browser has display issues with top/left and requires transform instead
Android 2 browser requires top/left or tiles disappear on load or first drag
(reappear after zoom) https://github.com/CloudMade/Leaflet/issues/866
(other browsers don't currently care) - see debug/hacks/jitter.html for an example
*/
L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome || L.Browser.android23);
L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome);
this._tiles[tilePoint.x + ':' + tilePoint.y] = tile;
@ -2881,14 +2870,12 @@ L.TileLayer = L.Class.extend({
zoom = options.maxZoom - zoom;
}
zoom += options.zoomOffset;
return options.maxNativeZoom ? Math.min(zoom, options.maxNativeZoom) : zoom;
return zoom + options.zoomOffset;
},
_getTilePos: function (tilePoint) {
var origin = this._map.getPixelOrigin(),
tileSize = this._getTileSize();
tileSize = this.options.tileSize;
return tilePoint.multiplyBy(tileSize).subtract(origin);
},
@ -2931,6 +2918,12 @@ 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();
@ -2944,10 +2937,7 @@ L.TileLayer = L.Class.extend({
_resetTile: function (/*tile*/) {},
_createTile: function () {
var tile = L.DomUtil.create('img', 'leaflet-tile');
tile.style.width = tile.style.height = this._getTileSize() + 'px';
tile.galleryimg = 'no';
var tile = this._tileImg.cloneNode(false);
tile.onselectstart = tile.onmousemove = L.Util.falseFn;
if (L.Browser.ielt9 && this.options.opacity !== undefined) {
@ -3150,9 +3140,13 @@ 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 = L.DomUtil.create('canvas', 'leaflet-tile');
tile.width = tile.height = this.options.tileSize;
var tile = this._canvasProto.cloneNode(false);
tile.onselectstart = tile.onmousemove = L.Util.falseFn;
return tile;
},
@ -4481,10 +4475,10 @@ L.FeatureGroup = L.LayerGroup.extend({
},
_propagateEvent: function (e) {
e = L.extend({}, e, {
e = L.extend({
layer: e.target,
target: this
});
}, e);
this.fire(e.type, e);
}
});
@ -5255,7 +5249,7 @@ L.Map.include((L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? {}
* and polylines (clipping, simplification, distances, etc.)
*/
/*jshint bitwise:false */ // allow bitwise oprations for this file
/*jshint bitwise:false */ // allow bitwise operations for this file
L.LineUtil = {
@ -5988,6 +5982,7 @@ L.CircleMarker = L.Circle.extend({
if (this._popup && this._popup._isOpen) {
this._popup.setLatLng(latlng);
}
return this;
},
setRadius: function (radius) {
@ -6769,7 +6764,7 @@ L.Draggable = L.Class.extend({
L.DomUtil.enableImageDrag();
L.DomUtil.enableTextSelection();
if (this._moved) {
if (this._moved && this._moving) {
// ensure drag is not fired after dragend
L.Util.cancelAnimFrame(this._animRequest);
@ -8903,8 +8898,8 @@ if (L.DomUtil.TRANSITION) {
L.Map.include(!L.DomUtil.TRANSITION ? {} : {
_catchTransitionEnd: function () {
if (this._animatingZoom) {
_catchTransitionEnd: function (e) {
if (this._animatingZoom && e.propertyName.indexOf('transform') >= 0) {
this._onZoomTransitionEnd();
}
},
@ -9188,4 +9183,4 @@ L.Map.include({
});
}(window, document));
}(window, document));