fix superclass regression
This commit is contained in:
parent
9081e9a00c
commit
b333f86e1d
316
dist/leaflet-src.js
vendored
316
dist/leaflet-src.js
vendored
@ -57,9 +57,10 @@ L.Util = {
|
|||||||
return dest;
|
return dest;
|
||||||
},
|
},
|
||||||
|
|
||||||
bind: function (/*Function*/ fn, /*Object*/ obj) /*-> Object*/ {
|
bind: function (fn, obj) { // (Function, Object) -> Function
|
||||||
|
var args = Array.prototype.slice.call(arguments, 2);
|
||||||
return function () {
|
return function () {
|
||||||
return fn.apply(obj, arguments);
|
return fn.apply(obj, args || arguments);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -142,6 +143,7 @@ L.Util = {
|
|||||||
|
|
||||||
setOptions: function (obj, options) {
|
setOptions: function (obj, options) {
|
||||||
obj.options = L.Util.extend({}, obj.options, options);
|
obj.options = L.Util.extend({}, obj.options, options);
|
||||||
|
return obj.options;
|
||||||
},
|
},
|
||||||
|
|
||||||
getParamString: function (obj) {
|
getParamString: function (obj) {
|
||||||
@ -752,16 +754,21 @@ L.LatLngBounds = L.Class.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// extend the bounds to contain the given point
|
// extend the bounds to contain the given point or bounds
|
||||||
extend: function (/*LatLng*/ latlng) {
|
extend: function (/*LatLng or LatLngBounds*/ obj) {
|
||||||
if (!this._southWest && !this._northEast) {
|
if (obj instanceof L.LatLng) {
|
||||||
this._southWest = new L.LatLng(latlng.lat, latlng.lng, true);
|
if (!this._southWest && !this._northEast) {
|
||||||
this._northEast = new L.LatLng(latlng.lat, latlng.lng, true);
|
this._southWest = new L.LatLng(obj.lat, obj.lng, true);
|
||||||
} else {
|
this._northEast = new L.LatLng(obj.lat, obj.lng, true);
|
||||||
this._southWest.lat = Math.min(latlng.lat, this._southWest.lat);
|
} else {
|
||||||
this._southWest.lng = Math.min(latlng.lng, this._southWest.lng);
|
this._southWest.lat = Math.min(obj.lat, this._southWest.lat);
|
||||||
this._northEast.lat = Math.max(latlng.lat, this._northEast.lat);
|
this._southWest.lng = Math.min(obj.lng, this._southWest.lng);
|
||||||
this._northEast.lng = Math.max(latlng.lng, this._northEast.lng);
|
this._northEast.lat = Math.max(obj.lat, this._northEast.lat);
|
||||||
|
this._northEast.lng = Math.max(obj.lng, this._northEast.lng);
|
||||||
|
}
|
||||||
|
} else if (obj instanceof L.LatLngBounds) {
|
||||||
|
this.extend(obj._southWest);
|
||||||
|
this.extend(obj._northEast);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
@ -854,7 +861,7 @@ L.Projection = {};
|
|||||||
L.Projection.SphericalMercator = {
|
L.Projection.SphericalMercator = {
|
||||||
MAX_LATITUDE: 85.0511287798,
|
MAX_LATITUDE: 85.0511287798,
|
||||||
|
|
||||||
project: function (/*LatLng*/ latlng) /*-> Point*/ {
|
project: function (latlng) { // (LatLng) -> Point
|
||||||
var d = L.LatLng.DEG_TO_RAD,
|
var d = L.LatLng.DEG_TO_RAD,
|
||||||
max = this.MAX_LATITUDE,
|
max = this.MAX_LATITUDE,
|
||||||
lat = Math.max(Math.min(max, latlng.lat), -max),
|
lat = Math.max(Math.min(max, latlng.lat), -max),
|
||||||
@ -865,7 +872,7 @@ L.Projection.SphericalMercator = {
|
|||||||
return new L.Point(x, y);
|
return new L.Point(x, y);
|
||||||
},
|
},
|
||||||
|
|
||||||
unproject: function (/*Point*/ point, /*Boolean*/ unbounded) /*-> LatLng*/ {
|
unproject: function (point, unbounded) { // (Point, Boolean) -> LatLng
|
||||||
var d = L.LatLng.RAD_TO_DEG,
|
var d = L.LatLng.RAD_TO_DEG,
|
||||||
lng = point.x * d,
|
lng = point.x * d,
|
||||||
lat = (2 * Math.atan(Math.exp(point.y)) - (Math.PI / 2)) * d;
|
lat = (2 * Math.atan(Math.exp(point.y)) - (Math.PI / 2)) * d;
|
||||||
@ -889,19 +896,27 @@ L.Projection.LonLat = {
|
|||||||
|
|
||||||
|
|
||||||
L.CRS = {
|
L.CRS = {
|
||||||
latLngToPoint: function (/*LatLng*/ latlng, /*Number*/ scale)/*-> Point*/ {
|
latLngToPoint: function (latlng, zoom) { // (LatLng, Number) -> Point
|
||||||
var projectedPoint = this.projection.project(latlng);
|
var projectedPoint = this.projection.project(latlng),
|
||||||
|
scale = this.scale(zoom);
|
||||||
|
|
||||||
return this.transformation._transform(projectedPoint, scale);
|
return this.transformation._transform(projectedPoint, scale);
|
||||||
},
|
},
|
||||||
|
|
||||||
pointToLatLng: function (/*Point*/ point, /*Number*/ scale, /*(optional) Boolean*/ unbounded)/*-> LatLng*/ {
|
pointToLatLng: function (point, zoom, unbounded) { // (Point, Number[, Boolean]) -> LatLng
|
||||||
var untransformedPoint = this.transformation.untransform(point, scale);
|
var scale = this.scale(zoom),
|
||||||
|
untransformedPoint = this.transformation.untransform(point, scale);
|
||||||
|
|
||||||
return this.projection.unproject(untransformedPoint, unbounded);
|
return this.projection.unproject(untransformedPoint, unbounded);
|
||||||
//TODO get rid of 'unbounded' everywhere
|
//TODO get rid of 'unbounded' everywhere
|
||||||
},
|
},
|
||||||
|
|
||||||
project: function (latlng) {
|
project: function (latlng) {
|
||||||
return this.projection.project(latlng);
|
return this.projection.project(latlng);
|
||||||
|
},
|
||||||
|
|
||||||
|
scale: function (zoom) {
|
||||||
|
return 256 * Math.pow(2, zoom);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -913,7 +928,7 @@ L.CRS.EPSG3857 = L.Util.extend({}, L.CRS, {
|
|||||||
projection: L.Projection.SphericalMercator,
|
projection: L.Projection.SphericalMercator,
|
||||||
transformation: new L.Transformation(0.5 / Math.PI, 0.5, -0.5 / Math.PI, 0.5),
|
transformation: new L.Transformation(0.5 / Math.PI, 0.5, -0.5 / Math.PI, 0.5),
|
||||||
|
|
||||||
project: function (/*LatLng*/ latlng)/*-> Point*/ {
|
project: function (latlng) { // (LatLng) -> Point
|
||||||
var projectedPoint = this.projection.project(latlng),
|
var projectedPoint = this.projection.project(latlng),
|
||||||
earthRadius = 6378137;
|
earthRadius = 6378137;
|
||||||
return projectedPoint.multiplyBy(earthRadius);
|
return projectedPoint.multiplyBy(earthRadius);
|
||||||
@ -942,66 +957,32 @@ L.Map = L.Class.extend({
|
|||||||
includes: L.Mixin.Events,
|
includes: L.Mixin.Events,
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
// projection
|
crs: L.CRS.EPSG3857,
|
||||||
crs: L.CRS.EPSG3857 || L.CRS.EPSG4326,
|
|
||||||
scale: function (zoom) {
|
|
||||||
return 256 * Math.pow(2, zoom);
|
|
||||||
},
|
|
||||||
|
|
||||||
// state
|
/*
|
||||||
center: null,
|
center: LatLng,
|
||||||
zoom: null,
|
zoom: Number,
|
||||||
layers: [],
|
layers: Array,
|
||||||
|
*/
|
||||||
|
|
||||||
// controls
|
|
||||||
zoomControl: true,
|
|
||||||
attributionControl: true,
|
|
||||||
|
|
||||||
// animation
|
|
||||||
fadeAnimation: L.DomUtil.TRANSITION && !L.Browser.android,
|
fadeAnimation: L.DomUtil.TRANSITION && !L.Browser.android,
|
||||||
zoomAnimation: L.DomUtil.TRANSITION && !L.Browser.android && !L.Browser.mobileOpera,
|
trackResize: true
|
||||||
|
|
||||||
// misc
|
|
||||||
trackResize: true,
|
|
||||||
worldCopyJump: true
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
initialize: function (id, options) { // (HTMLElement or String, Object)
|
initialize: function (id, options) { // (HTMLElement or String, Object)
|
||||||
L.Util.setOptions(this, options);
|
options = L.Util.setOptions(this, options);
|
||||||
|
|
||||||
// TODO method is too big, refactor
|
|
||||||
|
|
||||||
var container = this._container = L.DomUtil.get(id);
|
|
||||||
|
|
||||||
if (container._leaflet) {
|
|
||||||
throw new Error("Map container is already initialized.");
|
|
||||||
}
|
|
||||||
container._leaflet = true;
|
|
||||||
|
|
||||||
|
this._initContainer(id);
|
||||||
this._initLayout();
|
this._initLayout();
|
||||||
|
this._initHooks();
|
||||||
if (L.DomEvent) {
|
this._initEvents();
|
||||||
this._initEvents();
|
|
||||||
if (L.Handler) {
|
|
||||||
this._initInteraction();
|
|
||||||
}
|
|
||||||
if (L.Control) {
|
|
||||||
this._initControls();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
options = this.options;
|
|
||||||
|
|
||||||
if (options.maxBounds) {
|
if (options.maxBounds) {
|
||||||
this.setMaxBounds(options.maxBounds);
|
this.setMaxBounds(options.maxBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
var center = options.center,
|
if (options.center && typeof options.zoom !== 'undefined') {
|
||||||
zoom = options.zoom;
|
this.setView(options.center, options.zoom, true);
|
||||||
|
|
||||||
if (center && typeof zoom !== 'undefined') {
|
|
||||||
this.setView(center, zoom, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._initLayers(options.layers);
|
this._initLayers(options.layers);
|
||||||
@ -1012,7 +993,6 @@ L.Map = L.Class.extend({
|
|||||||
|
|
||||||
// replaced by animation-powered implementation in Map.PanAnimation.js
|
// replaced by animation-powered implementation in Map.PanAnimation.js
|
||||||
setView: function (center, zoom) {
|
setView: function (center, zoom) {
|
||||||
// reset the map view
|
|
||||||
this._resetView(center, this._limitZoom(zoom));
|
this._resetView(center, this._limitZoom(zoom));
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
@ -1108,9 +1088,7 @@ L.Map = L.Class.extend({
|
|||||||
|
|
||||||
var id = L.Util.stamp(layer);
|
var id = L.Util.stamp(layer);
|
||||||
|
|
||||||
if (this._layers[id]) {
|
if (this._layers[id]) { return this; }
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._layers[id] = layer;
|
this._layers[id] = layer;
|
||||||
|
|
||||||
@ -1128,10 +1106,6 @@ L.Map = L.Class.extend({
|
|||||||
layer.on('load', this._onTileLayerLoad, this);
|
layer.on('load', this._onTileLayerLoad, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.attributionControl && layer.getAttribution) {
|
|
||||||
this.attributionControl.addAttribution(layer.getAttribution());
|
|
||||||
}
|
|
||||||
|
|
||||||
var onMapLoad = function () {
|
var onMapLoad = function () {
|
||||||
layer.onAdd(this, insertAtTheBottom);
|
layer.onAdd(this, insertAtTheBottom);
|
||||||
this.fire('layeradd', {layer: layer});
|
this.fire('layeradd', {layer: layer});
|
||||||
@ -1161,10 +1135,6 @@ L.Map = L.Class.extend({
|
|||||||
layer.off('load', this._onTileLayerLoad, this);
|
layer.off('load', this._onTileLayerLoad, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.attributionControl && layer.getAttribution) {
|
|
||||||
this.attributionControl.removeAttribution(layer.getAttribution());
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.fire('layerremove', {layer: layer});
|
return this.fire('layerremove', {layer: layer});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1189,16 +1159,13 @@ L.Map = L.Class.extend({
|
|||||||
|
|
||||||
this.fire('move');
|
this.fire('move');
|
||||||
|
|
||||||
function fireMoveEnd() {
|
|
||||||
this.fire('moveend');
|
|
||||||
}
|
|
||||||
|
|
||||||
clearTimeout(this._sizeTimer);
|
clearTimeout(this._sizeTimer);
|
||||||
this._sizeTimer = setTimeout(L.Util.bind(fireMoveEnd, this), 200);
|
this._sizeTimer = setTimeout(L.Util.bind(this.fire, this, 'moveend'), 200);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// TODO handler.addTo
|
||||||
addHandler: function (name, HandlerClass) {
|
addHandler: function (name, HandlerClass) {
|
||||||
if (!HandlerClass) { return; }
|
if (!HandlerClass) { return; }
|
||||||
|
|
||||||
@ -1214,7 +1181,7 @@ L.Map = L.Class.extend({
|
|||||||
|
|
||||||
// public methods for getting map state
|
// public methods for getting map state
|
||||||
|
|
||||||
getCenter: function (unbounded) { // (Boolean)
|
getCenter: function (unbounded) { // (Boolean) -> LatLng
|
||||||
var viewHalf = this.getSize().divideBy(2),
|
var viewHalf = this.getSize().divideBy(2),
|
||||||
centerPoint = this._getTopLeftPoint().add(viewHalf);
|
centerPoint = this._getTopLeftPoint().add(viewHalf);
|
||||||
|
|
||||||
@ -1348,18 +1315,28 @@ L.Map = L.Class.extend({
|
|||||||
|
|
||||||
project: function (latlng, zoom) { // (LatLng[, Number]) -> Point
|
project: function (latlng, zoom) { // (LatLng[, Number]) -> Point
|
||||||
zoom = typeof zoom === 'undefined' ? this._zoom : zoom;
|
zoom = typeof zoom === 'undefined' ? this._zoom : zoom;
|
||||||
return this.options.crs.latLngToPoint(latlng, this.options.scale(zoom));
|
return this.options.crs.latLngToPoint(latlng, zoom);
|
||||||
},
|
},
|
||||||
|
|
||||||
unproject: function (point, zoom, unbounded) { // (Point[, Number, Boolean]) -> LatLng
|
unproject: function (point, zoom, unbounded) { // (Point[, Number, Boolean]) -> LatLng
|
||||||
// TODO remove unbounded, making it true all the time?
|
// TODO remove unbounded, making it true all the time?
|
||||||
zoom = typeof zoom === 'undefined' ? this._zoom : zoom;
|
zoom = typeof zoom === 'undefined' ? this._zoom : zoom;
|
||||||
return this.options.crs.pointToLatLng(point, this.options.scale(zoom), unbounded);
|
return this.options.crs.pointToLatLng(point, zoom, unbounded);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// private methods that modify map state
|
// private methods that modify map state
|
||||||
|
|
||||||
|
_initContainer: function (id) {
|
||||||
|
var container = this._container = L.DomUtil.get(id);
|
||||||
|
|
||||||
|
if (container._leaflet) {
|
||||||
|
throw new Error("Map container is already initialized.");
|
||||||
|
}
|
||||||
|
|
||||||
|
container._leaflet = true;
|
||||||
|
},
|
||||||
|
|
||||||
_initLayout: function () {
|
_initLayout: function () {
|
||||||
var container = this._container;
|
var container = this._container;
|
||||||
|
|
||||||
@ -1405,6 +1382,15 @@ L.Map = L.Class.extend({
|
|||||||
return L.DomUtil.create('div', className, container || this._objectsPane);
|
return L.DomUtil.create('div', className, container || this._objectsPane);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_initializers: [],
|
||||||
|
|
||||||
|
_initHooks: function () {
|
||||||
|
var i, len;
|
||||||
|
for (i = 0, len = this._initializers.length; i < len; i++) {
|
||||||
|
this._initializers[i].call(this);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_resetView: function (center, zoom, preserveMapOffset, afterZoomAnim) {
|
_resetView: function (center, zoom, preserveMapOffset, afterZoomAnim) {
|
||||||
|
|
||||||
var zoomChanged = (this._zoom !== zoom);
|
var zoomChanged = (this._zoom !== zoom);
|
||||||
@ -1446,7 +1432,7 @@ L.Map = L.Class.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_initLayers: function (layers) {
|
_initLayers: function (layers) {
|
||||||
layers = layers instanceof Array ? layers : [layers];
|
layers = layers ? (layers instanceof Array ? layers : [layers]) : [];
|
||||||
|
|
||||||
this._layers = {};
|
this._layers = {};
|
||||||
this._tileLayersNum = 0;
|
this._tileLayersNum = 0;
|
||||||
@ -1458,18 +1444,6 @@ L.Map = L.Class.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_initControls: function () {
|
|
||||||
// TODO refactor, this should happen automatically
|
|
||||||
if (this.options.zoomControl) {
|
|
||||||
this.zoomControl = new L.Control.Zoom();
|
|
||||||
this.addControl(this.zoomControl);
|
|
||||||
}
|
|
||||||
if (this.options.attributionControl) {
|
|
||||||
this.attributionControl = new L.Control.Attribution();
|
|
||||||
this.addControl(this.attributionControl);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_rawPanBy: function (offset) {
|
_rawPanBy: function (offset) {
|
||||||
var newPos = L.DomUtil.getPosition(this._mapPane).subtract(offset);
|
var newPos = L.DomUtil.getPosition(this._mapPane).subtract(offset);
|
||||||
L.DomUtil.setPosition(this._mapPane, newPos);
|
L.DomUtil.setPosition(this._mapPane, newPos);
|
||||||
@ -1479,6 +1453,8 @@ L.Map = L.Class.extend({
|
|||||||
// map events
|
// map events
|
||||||
|
|
||||||
_initEvents: function () {
|
_initEvents: function () {
|
||||||
|
if (!L.DomEvent) { return; }
|
||||||
|
|
||||||
L.DomEvent.addListener(this._container, 'click', this._onMouseClick, this);
|
L.DomEvent.addListener(this._container, 'click', this._onMouseClick, this);
|
||||||
|
|
||||||
var events = ['dblclick', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'contextmenu'];
|
var events = ['dblclick', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'contextmenu'];
|
||||||
@ -1530,15 +1506,6 @@ L.Map = L.Class.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_initInteraction: function () {
|
|
||||||
this
|
|
||||||
.addHandler('dragging', L.Map.Drag)
|
|
||||||
.addHandler('touchZoom', L.Map.TouchZoom)
|
|
||||||
.addHandler('doubleClickZoom', L.Map.DoubleClickZoom)
|
|
||||||
.addHandler('scrollWheelZoom', L.Map.ScrollWheelZoom)
|
|
||||||
.addHandler('boxZoom', L.Map.BoxZoom);
|
|
||||||
},
|
|
||||||
|
|
||||||
_onTileLayerLoad: function () {
|
_onTileLayerLoad: function () {
|
||||||
// TODO super-ugly, refactor!!!
|
// TODO super-ugly, refactor!!!
|
||||||
// clear scaled tiles after all new tiles are loaded (for performance)
|
// clear scaled tiles after all new tiles are loaded (for performance)
|
||||||
@ -1575,6 +1542,15 @@ L.Map = L.Class.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
L.Map.addInitHook = function (fn) {
|
||||||
|
var args = Array.prototype.slice.call(arguments, 1);
|
||||||
|
|
||||||
|
var init = typeof fn === 'function' ? fn : function () {
|
||||||
|
this[fn].apply(this, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.prototype._initializers.push(init);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
L.Projection.Mercator = {
|
L.Projection.Mercator = {
|
||||||
@ -1583,7 +1559,7 @@ L.Projection.Mercator = {
|
|||||||
R_MINOR: 6356752.3142,
|
R_MINOR: 6356752.3142,
|
||||||
R_MAJOR: 6378137,
|
R_MAJOR: 6378137,
|
||||||
|
|
||||||
project: function (/*LatLng*/ latlng) /*-> Point*/ {
|
project: function (latlng) { // (LatLng) -> Point
|
||||||
var d = L.LatLng.DEG_TO_RAD,
|
var d = L.LatLng.DEG_TO_RAD,
|
||||||
max = this.MAX_LATITUDE,
|
max = this.MAX_LATITUDE,
|
||||||
lat = Math.max(Math.min(max, latlng.lat), -max),
|
lat = Math.max(Math.min(max, latlng.lat), -max),
|
||||||
@ -1603,7 +1579,7 @@ L.Projection.Mercator = {
|
|||||||
return new L.Point(x, y);
|
return new L.Point(x, y);
|
||||||
},
|
},
|
||||||
|
|
||||||
unproject: function (/*Point*/ point, /*Boolean*/ unbounded) /*-> LatLng*/ {
|
unproject: function (point, unbounded) { // (Point, Boolean) -> LatLng
|
||||||
var d = L.LatLng.RAD_TO_DEG,
|
var d = L.LatLng.RAD_TO_DEG,
|
||||||
r = this.R_MAJOR,
|
r = this.R_MAJOR,
|
||||||
r2 = this.R_MINOR,
|
r2 = this.R_MINOR,
|
||||||
@ -1634,6 +1610,7 @@ L.CRS.EPSG3395 = L.Util.extend({}, L.CRS, {
|
|||||||
code: 'EPSG:3395',
|
code: 'EPSG:3395',
|
||||||
|
|
||||||
projection: L.Projection.Mercator,
|
projection: L.Projection.Mercator,
|
||||||
|
|
||||||
transformation: (function () {
|
transformation: (function () {
|
||||||
var m = L.Projection.Mercator,
|
var m = L.Projection.Mercator,
|
||||||
r = m.R_MAJOR,
|
r = m.R_MAJOR,
|
||||||
@ -2558,9 +2535,14 @@ L.Popup = L.Class.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_close: function () {
|
_close: function () {
|
||||||
if (this._map) {
|
var map = this._map;
|
||||||
this._map._popup = null;
|
|
||||||
this._map.removeLayer(this);
|
if (map) {
|
||||||
|
map._popup = null;
|
||||||
|
|
||||||
|
map
|
||||||
|
.removeLayer(this)
|
||||||
|
.fire('popupclose', {popup: this});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2609,6 +2591,7 @@ L.Popup = L.Class.extend({
|
|||||||
this._contentNode.innerHTML = '';
|
this._contentNode.innerHTML = '';
|
||||||
this._contentNode.appendChild(this._content);
|
this._contentNode.appendChild(this._content);
|
||||||
}
|
}
|
||||||
|
this.fire('contentupdate');
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateLayout: function () {
|
_updateLayout: function () {
|
||||||
@ -2755,11 +2738,7 @@ L.Map.include({
|
|||||||
|
|
||||||
closePopup: function () {
|
closePopup: function () {
|
||||||
if (this._popup) {
|
if (this._popup) {
|
||||||
this
|
this._popup._close();
|
||||||
.removeLayer(this._popup)
|
|
||||||
.fire('popupclose', {popup: this._popup});
|
|
||||||
|
|
||||||
this._popup = null;
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -2874,6 +2853,14 @@ L.FeatureGroup = L.LayerGroup.extend({
|
|||||||
return this.invoke('setStyle', style);
|
return this.invoke('setStyle', style);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getBounds: function () {
|
||||||
|
var bounds = new L.LatLngBounds();
|
||||||
|
this._iterateLayers(function (layer) {
|
||||||
|
bounds.extend(layer instanceof L.Marker ? layer.getLatLng() : layer.getBounds());
|
||||||
|
}, this);
|
||||||
|
return bounds;
|
||||||
|
},
|
||||||
|
|
||||||
_initEvents: function (layer) {
|
_initEvents: function (layer) {
|
||||||
var events = ['click', 'dblclick', 'mouseover', 'mouseout'],
|
var events = ['click', 'dblclick', 'mouseover', 'mouseout'],
|
||||||
i, len;
|
i, len;
|
||||||
@ -3728,7 +3715,7 @@ L.Polyline = L.Path.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_initEvents: function () {
|
_initEvents: function () {
|
||||||
L.Polyline.superclass._initEvents.call(this);
|
L.Path.prototype._initEvents.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
_getPathPartStr: function (points) {
|
_getPathPartStr: function (points) {
|
||||||
@ -4648,10 +4635,15 @@ L.Handler = L.Class.extend({
|
|||||||
|
|
||||||
L.Map.mergeOptions({
|
L.Map.mergeOptions({
|
||||||
dragging: true,
|
dragging: true,
|
||||||
|
|
||||||
inertia: !L.Browser.android,
|
inertia: !L.Browser.android,
|
||||||
inertiaDeceleration: L.Browser.touch ? 3000 : 2000, // px/s^2
|
inertiaDeceleration: L.Browser.touch ? 3000 : 2000, // px/s^2
|
||||||
inertiaMaxSpeed: L.Browser.touch ? 1500 : 1000, // px/s
|
inertiaMaxSpeed: L.Browser.touch ? 1500 : 1000, // px/s
|
||||||
inertiaThreshold: L.Browser.touch ? 32 : 16 // ms
|
inertiaThreshold: L.Browser.touch ? 32 : 16, // ms
|
||||||
|
|
||||||
|
// TODO refactor, move to CRS
|
||||||
|
worldCopyJump: true,
|
||||||
|
continuousWorld: false
|
||||||
});
|
});
|
||||||
|
|
||||||
L.Map.Drag = L.Handler.extend({
|
L.Map.Drag = L.Handler.extend({
|
||||||
@ -4727,7 +4719,7 @@ L.Map.Drag = L.Handler.extend({
|
|||||||
|
|
||||||
_onPreDrag: function () {
|
_onPreDrag: function () {
|
||||||
var map = this._map,
|
var map = this._map,
|
||||||
worldWidth = map.options.scale(map.getZoom()),
|
worldWidth = map.options.crs.scale(map.getZoom()),
|
||||||
halfWidth = Math.round(worldWidth / 2),
|
halfWidth = Math.round(worldWidth / 2),
|
||||||
dx = this._initialWorldOffset.x,
|
dx = this._initialWorldOffset.x,
|
||||||
x = this._draggable._newPos.x,
|
x = this._draggable._newPos.x,
|
||||||
@ -4787,6 +4779,7 @@ L.Map.Drag = L.Handler.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
L.Map.addInitHook('addHandler', 'dragging', L.Map.Drag);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* L.Handler.DoubleClickZoom is used internally by L.Map to add double-click zooming.
|
* L.Handler.DoubleClickZoom is used internally by L.Map to add double-click zooming.
|
||||||
@ -4810,6 +4803,7 @@ L.Map.DoubleClickZoom = L.Handler.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* L.Handler.ScrollWheelZoom is used internally by L.Map to enable mouse scroll wheel zooming on the map.
|
* L.Handler.ScrollWheelZoom is used internally by L.Map to enable mouse scroll wheel zooming on the map.
|
||||||
@ -4870,6 +4864,7 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
L.Map.addInitHook('addHandler', 'scrollWheelZoom', L.Map.ScrollWheelZoom);
|
||||||
|
|
||||||
L.Util.extend(L.DomEvent, {
|
L.Util.extend(L.DomEvent, {
|
||||||
// inspired by Zepto touch code by Thomas Fuchs
|
// inspired by Zepto touch code by Thomas Fuchs
|
||||||
@ -5014,6 +5009,7 @@ L.Map.TouchZoom = L.Handler.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
L.Map.addInitHook('addHandler', 'touchZoom', L.Map.TouchZoom);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* L.Handler.ShiftDragZoom is used internally by L.Map to add shift-drag zoom (zoom to a selected bounding box).
|
* L.Handler.ShiftDragZoom is used internally by L.Map to add shift-drag zoom (zoom to a selected bounding box).
|
||||||
@ -5055,6 +5051,8 @@ L.Map.BoxZoom = L.Handler.extend({
|
|||||||
.addListener(document, 'mousemove', this._onMouseMove, this)
|
.addListener(document, 'mousemove', this._onMouseMove, this)
|
||||||
.addListener(document, 'mouseup', this._onMouseUp, this)
|
.addListener(document, 'mouseup', this._onMouseUp, this)
|
||||||
.preventDefault(e);
|
.preventDefault(e);
|
||||||
|
|
||||||
|
this._map.fire("boxzoomstart");
|
||||||
},
|
},
|
||||||
|
|
||||||
_onMouseMove: function (e) {
|
_onMouseMove: function (e) {
|
||||||
@ -5093,9 +5091,15 @@ L.Map.BoxZoom = L.Handler.extend({
|
|||||||
map.layerPointToLatLng(layerPoint));
|
map.layerPointToLatLng(layerPoint));
|
||||||
|
|
||||||
map.fitBounds(bounds);
|
map.fitBounds(bounds);
|
||||||
|
|
||||||
|
map.fire("boxzoomend", {
|
||||||
|
boxZoomBounds: bounds
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
L.Map.addInitHook('addHandler', 'boxZoom', L.Map.BoxZoom);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable.
|
* L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable.
|
||||||
@ -5179,6 +5183,8 @@ L.Handler.PolyEdit = L.Handler.extend({
|
|||||||
removeHooks: function () {
|
removeHooks: function () {
|
||||||
if (this._poly._map) {
|
if (this._poly._map) {
|
||||||
this._poly._map.removeLayer(this._markerGroup);
|
this._poly._map.removeLayer(this._markerGroup);
|
||||||
|
delete this._markerGroup;
|
||||||
|
delete this._markers;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -5293,13 +5299,16 @@ L.Handler.PolyEdit = L.Handler.extend({
|
|||||||
|
|
||||||
_createMiddleMarker: function (marker1, marker2) {
|
_createMiddleMarker: function (marker1, marker2) {
|
||||||
var latlng = this._getMiddleLatLng(marker1, marker2),
|
var latlng = this._getMiddleLatLng(marker1, marker2),
|
||||||
marker = this._createMarker(latlng);
|
marker = this._createMarker(latlng),
|
||||||
|
onClick,
|
||||||
|
onDragStart,
|
||||||
|
onDragEnd;
|
||||||
|
|
||||||
marker.setOpacity(0.6);
|
marker.setOpacity(0.6);
|
||||||
|
|
||||||
marker1._middleRight = marker2._middleLeft = marker;
|
marker1._middleRight = marker2._middleLeft = marker;
|
||||||
|
|
||||||
function onDragStart() {
|
onDragStart = function () {
|
||||||
var i = marker2._index;
|
var i = marker2._index;
|
||||||
|
|
||||||
marker._index = i;
|
marker._index = i;
|
||||||
@ -5317,21 +5326,21 @@ L.Handler.PolyEdit = L.Handler.extend({
|
|||||||
marker2._index++;
|
marker2._index++;
|
||||||
this._updatePrevNext(marker1, marker);
|
this._updatePrevNext(marker1, marker);
|
||||||
this._updatePrevNext(marker, marker2);
|
this._updatePrevNext(marker, marker2);
|
||||||
}
|
};
|
||||||
|
|
||||||
function onDragEnd() {
|
onDragEnd = function () {
|
||||||
marker.off('dragstart', onDragStart, this);
|
marker.off('dragstart', onDragStart, this);
|
||||||
marker.off('dragend', onDragEnd, this);
|
marker.off('dragend', onDragEnd, this);
|
||||||
|
|
||||||
this._createMiddleMarker(marker1, marker);
|
this._createMiddleMarker(marker1, marker);
|
||||||
this._createMiddleMarker(marker, marker2);
|
this._createMiddleMarker(marker, marker2);
|
||||||
}
|
};
|
||||||
|
|
||||||
function onClick() {
|
onClick = function () {
|
||||||
onDragStart.call(this);
|
onDragStart.call(this);
|
||||||
onDragEnd.call(this);
|
onDragEnd.call(this);
|
||||||
this._poly.fire('edit');
|
this._poly.fire('edit');
|
||||||
}
|
};
|
||||||
|
|
||||||
marker
|
marker
|
||||||
.on('click', onClick, this)
|
.on('click', onClick, this)
|
||||||
@ -5454,7 +5463,7 @@ L.Control.Zoom = L.Control.extend({
|
|||||||
onAdd: function (map) {
|
onAdd: function (map) {
|
||||||
var className = 'leaflet-control-zoom',
|
var className = 'leaflet-control-zoom',
|
||||||
container = L.DomUtil.create('div', className);
|
container = L.DomUtil.create('div', className);
|
||||||
|
|
||||||
this._createButton('Zoom in', className + '-in', container, map.zoomIn, map);
|
this._createButton('Zoom in', className + '-in', container, map.zoomIn, map);
|
||||||
this._createButton('Zoom out', className + '-out', container, map.zoomOut, map);
|
this._createButton('Zoom out', className + '-out', container, map.zoomOut, map);
|
||||||
|
|
||||||
@ -5475,6 +5484,16 @@ L.Control.Zoom = L.Control.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
L.Map.mergeOptions({
|
||||||
|
zoomControl: true
|
||||||
|
});
|
||||||
|
|
||||||
|
L.Map.addInitHook(function () {
|
||||||
|
if (this.options.zoomControl) {
|
||||||
|
this.zoomControl = new L.Control.Zoom();
|
||||||
|
this.addControl(this.zoomControl);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
L.Control.Attribution = L.Control.extend({
|
L.Control.Attribution = L.Control.extend({
|
||||||
options: {
|
options: {
|
||||||
@ -5489,16 +5508,25 @@ L.Control.Attribution = L.Control.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onAdd: function (map) {
|
onAdd: function (map) {
|
||||||
this._map = map;
|
|
||||||
|
|
||||||
this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
|
this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
|
||||||
L.DomEvent.disableClickPropagation(this._container);
|
L.DomEvent.disableClickPropagation(this._container);
|
||||||
|
|
||||||
|
map
|
||||||
|
.on('layeradd', this._onLayerAdd, this)
|
||||||
|
.on('layerremove', this._onLayerRemove, this);
|
||||||
|
|
||||||
this._update();
|
this._update();
|
||||||
|
|
||||||
return this._container;
|
return this._container;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onRemove: function (map) {
|
||||||
|
map
|
||||||
|
.off('layeradd', this._onLayerAdd)
|
||||||
|
.off('layerremove', this._onLayerRemove);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
setPrefix: function (prefix) {
|
setPrefix: function (prefix) {
|
||||||
this.options.prefix = prefix;
|
this.options.prefix = prefix;
|
||||||
this._update();
|
this._update();
|
||||||
@ -5543,9 +5571,30 @@ L.Control.Attribution = L.Control.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._container.innerHTML = prefixAndAttribs.join(' — ');
|
this._container.innerHTML = prefixAndAttribs.join(' — ');
|
||||||
|
},
|
||||||
|
|
||||||
|
_onLayerAdd: function (e) {
|
||||||
|
if (e.layer.getAttribution) {
|
||||||
|
this.addAttribution(e.layer.getAttribution());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_onLayerRemove: function (e) {
|
||||||
|
if (e.layer.getAttribution) {
|
||||||
|
this.removeAttribution(e.layer.getAttribution());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
L.Map.mergeOptions({
|
||||||
|
attributionControl: true
|
||||||
|
});
|
||||||
|
|
||||||
|
L.Map.addInitHook(function () {
|
||||||
|
if (this.options.attributionControl) {
|
||||||
|
this.attributionControl = (new L.Control.Attribution()).addTo(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
L.Control.Scale = L.Control.extend({
|
L.Control.Scale = L.Control.extend({
|
||||||
options: {
|
options: {
|
||||||
@ -6075,6 +6124,7 @@ L.Transition = L.Transition.NATIVE ? L.Transition : L.Transition.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
L.Map.include(!(L.Transition && L.Transition.implemented()) ? {} : {
|
L.Map.include(!(L.Transition && L.Transition.implemented()) ? {} : {
|
||||||
setView: function (center, zoom, forceReset) {
|
setView: function (center, zoom, forceReset) {
|
||||||
zoom = this._limitZoom(zoom);
|
zoom = this._limitZoom(zoom);
|
||||||
@ -6155,6 +6205,10 @@ L.Map.include(!(L.Transition && L.Transition.implemented()) ? {} : {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
L.Map.mergeOptions({
|
||||||
|
zoomAnimation: L.DomUtil.TRANSITION && !L.Browser.android && !L.Browser.mobileOpera
|
||||||
|
});
|
||||||
|
|
||||||
L.Map.include(!L.DomUtil.TRANSITION ? {} : {
|
L.Map.include(!L.DomUtil.TRANSITION ? {} : {
|
||||||
_zoomToIfCenterInView: function (center, zoom, centerOffset) {
|
_zoomToIfCenterInView: function (center, zoom, centerOffset) {
|
||||||
|
|
||||||
|
2
dist/leaflet.js
vendored
2
dist/leaflet.js
vendored
File diff suppressed because one or more lines are too long
@ -46,6 +46,7 @@ describe("Class", function() {
|
|||||||
expect(method).toHaveBeenCalled();
|
expect(method).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* superclass deprecated
|
||||||
it("should grant the ability to call parent methods, including constructor", function() {
|
it("should grant the ability to call parent methods, including constructor", function() {
|
||||||
var Klass2 = Klass.extend({
|
var Klass2 = Klass.extend({
|
||||||
initialize: function() {},
|
initialize: function() {},
|
||||||
@ -60,7 +61,7 @@ describe("Class", function() {
|
|||||||
|
|
||||||
b.constructor.superclass.bar.call(this);
|
b.constructor.superclass.bar.call(this);
|
||||||
expect(method).toHaveBeenCalled();
|
expect(method).toHaveBeenCalled();
|
||||||
});
|
}); */
|
||||||
|
|
||||||
it("should support static properties", function() {
|
it("should support static properties", function() {
|
||||||
expect(Klass.bla).toEqual(1);
|
expect(Klass.bla).toEqual(1);
|
||||||
@ -123,6 +124,7 @@ describe("Class", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* superclass deprecated
|
||||||
it("should have working superclass access with inheritance level > 2", function() {
|
it("should have working superclass access with inheritance level > 2", function() {
|
||||||
var constructor2 = jasmine.createSpy("Klass2 constructor"),
|
var constructor2 = jasmine.createSpy("Klass2 constructor"),
|
||||||
constructor3 = jasmine.createSpy("Klass3 constructor");
|
constructor3 = jasmine.createSpy("Klass3 constructor");
|
||||||
@ -149,5 +151,6 @@ describe("Class", function() {
|
|||||||
expect(constructor2).toHaveBeenCalled();
|
expect(constructor2).toHaveBeenCalled();
|
||||||
expect(constructor).toHaveBeenCalled();
|
expect(constructor).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -104,7 +104,7 @@ L.Polyline = L.Path.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_initEvents: function () {
|
_initEvents: function () {
|
||||||
L.Polyline.superclass._initEvents.call(this);
|
L.Path.prototype._initEvents.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
_getPathPartStr: function (points) {
|
_getPathPartStr: function (points) {
|
||||||
|
Loading…
Reference in New Issue
Block a user