fix superclass regression
This commit is contained in:
parent
9081e9a00c
commit
b333f86e1d
314
dist/leaflet-src.js
vendored
314
dist/leaflet-src.js
vendored
@ -57,9 +57,10 @@ L.Util = {
|
||||
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 fn.apply(obj, arguments);
|
||||
return fn.apply(obj, args || arguments);
|
||||
};
|
||||
},
|
||||
|
||||
@ -142,6 +143,7 @@ L.Util = {
|
||||
|
||||
setOptions: function (obj, options) {
|
||||
obj.options = L.Util.extend({}, obj.options, options);
|
||||
return obj.options;
|
||||
},
|
||||
|
||||
getParamString: function (obj) {
|
||||
@ -752,16 +754,21 @@ L.LatLngBounds = L.Class.extend({
|
||||
}
|
||||
},
|
||||
|
||||
// extend the bounds to contain the given point
|
||||
extend: function (/*LatLng*/ latlng) {
|
||||
if (!this._southWest && !this._northEast) {
|
||||
this._southWest = new L.LatLng(latlng.lat, latlng.lng, true);
|
||||
this._northEast = new L.LatLng(latlng.lat, latlng.lng, true);
|
||||
} else {
|
||||
this._southWest.lat = Math.min(latlng.lat, this._southWest.lat);
|
||||
this._southWest.lng = Math.min(latlng.lng, this._southWest.lng);
|
||||
this._northEast.lat = Math.max(latlng.lat, this._northEast.lat);
|
||||
this._northEast.lng = Math.max(latlng.lng, this._northEast.lng);
|
||||
// extend the bounds to contain the given point or bounds
|
||||
extend: function (/*LatLng or LatLngBounds*/ obj) {
|
||||
if (obj instanceof L.LatLng) {
|
||||
if (!this._southWest && !this._northEast) {
|
||||
this._southWest = new L.LatLng(obj.lat, obj.lng, true);
|
||||
this._northEast = new L.LatLng(obj.lat, obj.lng, true);
|
||||
} else {
|
||||
this._southWest.lat = Math.min(obj.lat, this._southWest.lat);
|
||||
this._southWest.lng = Math.min(obj.lng, this._southWest.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;
|
||||
},
|
||||
@ -854,7 +861,7 @@ L.Projection = {};
|
||||
L.Projection.SphericalMercator = {
|
||||
MAX_LATITUDE: 85.0511287798,
|
||||
|
||||
project: function (/*LatLng*/ latlng) /*-> Point*/ {
|
||||
project: function (latlng) { // (LatLng) -> Point
|
||||
var d = L.LatLng.DEG_TO_RAD,
|
||||
max = this.MAX_LATITUDE,
|
||||
lat = Math.max(Math.min(max, latlng.lat), -max),
|
||||
@ -865,7 +872,7 @@ L.Projection.SphericalMercator = {
|
||||
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,
|
||||
lng = point.x * d,
|
||||
lat = (2 * Math.atan(Math.exp(point.y)) - (Math.PI / 2)) * d;
|
||||
@ -889,19 +896,27 @@ L.Projection.LonLat = {
|
||||
|
||||
|
||||
L.CRS = {
|
||||
latLngToPoint: function (/*LatLng*/ latlng, /*Number*/ scale)/*-> Point*/ {
|
||||
var projectedPoint = this.projection.project(latlng);
|
||||
latLngToPoint: function (latlng, zoom) { // (LatLng, Number) -> Point
|
||||
var projectedPoint = this.projection.project(latlng),
|
||||
scale = this.scale(zoom);
|
||||
|
||||
return this.transformation._transform(projectedPoint, scale);
|
||||
},
|
||||
|
||||
pointToLatLng: function (/*Point*/ point, /*Number*/ scale, /*(optional) Boolean*/ unbounded)/*-> LatLng*/ {
|
||||
var untransformedPoint = this.transformation.untransform(point, scale);
|
||||
pointToLatLng: function (point, zoom, unbounded) { // (Point, Number[, Boolean]) -> LatLng
|
||||
var scale = this.scale(zoom),
|
||||
untransformedPoint = this.transformation.untransform(point, scale);
|
||||
|
||||
return this.projection.unproject(untransformedPoint, unbounded);
|
||||
//TODO get rid of 'unbounded' everywhere
|
||||
},
|
||||
|
||||
project: function (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,
|
||||
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),
|
||||
earthRadius = 6378137;
|
||||
return projectedPoint.multiplyBy(earthRadius);
|
||||
@ -942,66 +957,32 @@ L.Map = L.Class.extend({
|
||||
includes: L.Mixin.Events,
|
||||
|
||||
options: {
|
||||
// projection
|
||||
crs: L.CRS.EPSG3857 || L.CRS.EPSG4326,
|
||||
scale: function (zoom) {
|
||||
return 256 * Math.pow(2, zoom);
|
||||
},
|
||||
crs: L.CRS.EPSG3857,
|
||||
|
||||
// state
|
||||
center: null,
|
||||
zoom: null,
|
||||
layers: [],
|
||||
/*
|
||||
center: LatLng,
|
||||
zoom: Number,
|
||||
layers: Array,
|
||||
*/
|
||||
|
||||
// controls
|
||||
zoomControl: true,
|
||||
attributionControl: true,
|
||||
|
||||
// animation
|
||||
fadeAnimation: L.DomUtil.TRANSITION && !L.Browser.android,
|
||||
zoomAnimation: L.DomUtil.TRANSITION && !L.Browser.android && !L.Browser.mobileOpera,
|
||||
|
||||
// misc
|
||||
trackResize: true,
|
||||
worldCopyJump: true
|
||||
trackResize: true
|
||||
},
|
||||
|
||||
|
||||
initialize: function (id, options) { // (HTMLElement or String, Object)
|
||||
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;
|
||||
options = L.Util.setOptions(this, options);
|
||||
|
||||
this._initContainer(id);
|
||||
this._initLayout();
|
||||
|
||||
if (L.DomEvent) {
|
||||
this._initEvents();
|
||||
if (L.Handler) {
|
||||
this._initInteraction();
|
||||
}
|
||||
if (L.Control) {
|
||||
this._initControls();
|
||||
}
|
||||
}
|
||||
|
||||
options = this.options;
|
||||
this._initHooks();
|
||||
this._initEvents();
|
||||
|
||||
if (options.maxBounds) {
|
||||
this.setMaxBounds(options.maxBounds);
|
||||
}
|
||||
|
||||
var center = options.center,
|
||||
zoom = options.zoom;
|
||||
|
||||
if (center && typeof zoom !== 'undefined') {
|
||||
this.setView(center, zoom, true);
|
||||
if (options.center && typeof options.zoom !== 'undefined') {
|
||||
this.setView(options.center, options.zoom, true);
|
||||
}
|
||||
|
||||
this._initLayers(options.layers);
|
||||
@ -1012,7 +993,6 @@ L.Map = L.Class.extend({
|
||||
|
||||
// replaced by animation-powered implementation in Map.PanAnimation.js
|
||||
setView: function (center, zoom) {
|
||||
// reset the map view
|
||||
this._resetView(center, this._limitZoom(zoom));
|
||||
return this;
|
||||
},
|
||||
@ -1108,9 +1088,7 @@ L.Map = L.Class.extend({
|
||||
|
||||
var id = L.Util.stamp(layer);
|
||||
|
||||
if (this._layers[id]) {
|
||||
return this;
|
||||
}
|
||||
if (this._layers[id]) { return this; }
|
||||
|
||||
this._layers[id] = layer;
|
||||
|
||||
@ -1128,10 +1106,6 @@ L.Map = L.Class.extend({
|
||||
layer.on('load', this._onTileLayerLoad, this);
|
||||
}
|
||||
|
||||
if (this.attributionControl && layer.getAttribution) {
|
||||
this.attributionControl.addAttribution(layer.getAttribution());
|
||||
}
|
||||
|
||||
var onMapLoad = function () {
|
||||
layer.onAdd(this, insertAtTheBottom);
|
||||
this.fire('layeradd', {layer: layer});
|
||||
@ -1161,10 +1135,6 @@ L.Map = L.Class.extend({
|
||||
layer.off('load', this._onTileLayerLoad, this);
|
||||
}
|
||||
|
||||
if (this.attributionControl && layer.getAttribution) {
|
||||
this.attributionControl.removeAttribution(layer.getAttribution());
|
||||
}
|
||||
|
||||
return this.fire('layerremove', {layer: layer});
|
||||
},
|
||||
|
||||
@ -1189,16 +1159,13 @@ L.Map = L.Class.extend({
|
||||
|
||||
this.fire('move');
|
||||
|
||||
function fireMoveEnd() {
|
||||
this.fire('moveend');
|
||||
}
|
||||
|
||||
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;
|
||||
},
|
||||
|
||||
// TODO handler.addTo
|
||||
addHandler: function (name, HandlerClass) {
|
||||
if (!HandlerClass) { return; }
|
||||
|
||||
@ -1214,7 +1181,7 @@ L.Map = L.Class.extend({
|
||||
|
||||
// public methods for getting map state
|
||||
|
||||
getCenter: function (unbounded) { // (Boolean)
|
||||
getCenter: function (unbounded) { // (Boolean) -> LatLng
|
||||
var viewHalf = this.getSize().divideBy(2),
|
||||
centerPoint = this._getTopLeftPoint().add(viewHalf);
|
||||
|
||||
@ -1348,18 +1315,28 @@ L.Map = L.Class.extend({
|
||||
|
||||
project: function (latlng, zoom) { // (LatLng[, Number]) -> Point
|
||||
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
|
||||
// TODO remove unbounded, making it true all the time?
|
||||
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
|
||||
|
||||
_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 () {
|
||||
var container = this._container;
|
||||
|
||||
@ -1405,6 +1382,15 @@ L.Map = L.Class.extend({
|
||||
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) {
|
||||
|
||||
var zoomChanged = (this._zoom !== zoom);
|
||||
@ -1446,7 +1432,7 @@ L.Map = L.Class.extend({
|
||||
},
|
||||
|
||||
_initLayers: function (layers) {
|
||||
layers = layers instanceof Array ? layers : [layers];
|
||||
layers = layers ? (layers instanceof Array ? layers : [layers]) : [];
|
||||
|
||||
this._layers = {};
|
||||
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) {
|
||||
var newPos = L.DomUtil.getPosition(this._mapPane).subtract(offset);
|
||||
L.DomUtil.setPosition(this._mapPane, newPos);
|
||||
@ -1479,6 +1453,8 @@ L.Map = L.Class.extend({
|
||||
// map events
|
||||
|
||||
_initEvents: function () {
|
||||
if (!L.DomEvent) { return; }
|
||||
|
||||
L.DomEvent.addListener(this._container, 'click', this._onMouseClick, this);
|
||||
|
||||
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 () {
|
||||
// TODO super-ugly, refactor!!!
|
||||
// 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 = {
|
||||
@ -1583,7 +1559,7 @@ L.Projection.Mercator = {
|
||||
R_MINOR: 6356752.3142,
|
||||
R_MAJOR: 6378137,
|
||||
|
||||
project: function (/*LatLng*/ latlng) /*-> Point*/ {
|
||||
project: function (latlng) { // (LatLng) -> Point
|
||||
var d = L.LatLng.DEG_TO_RAD,
|
||||
max = this.MAX_LATITUDE,
|
||||
lat = Math.max(Math.min(max, latlng.lat), -max),
|
||||
@ -1603,7 +1579,7 @@ L.Projection.Mercator = {
|
||||
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,
|
||||
r = this.R_MAJOR,
|
||||
r2 = this.R_MINOR,
|
||||
@ -1634,6 +1610,7 @@ L.CRS.EPSG3395 = L.Util.extend({}, L.CRS, {
|
||||
code: 'EPSG:3395',
|
||||
|
||||
projection: L.Projection.Mercator,
|
||||
|
||||
transformation: (function () {
|
||||
var m = L.Projection.Mercator,
|
||||
r = m.R_MAJOR,
|
||||
@ -2558,9 +2535,14 @@ L.Popup = L.Class.extend({
|
||||
},
|
||||
|
||||
_close: function () {
|
||||
if (this._map) {
|
||||
this._map._popup = null;
|
||||
this._map.removeLayer(this);
|
||||
var map = this._map;
|
||||
|
||||
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.appendChild(this._content);
|
||||
}
|
||||
this.fire('contentupdate');
|
||||
},
|
||||
|
||||
_updateLayout: function () {
|
||||
@ -2755,11 +2738,7 @@ L.Map.include({
|
||||
|
||||
closePopup: function () {
|
||||
if (this._popup) {
|
||||
this
|
||||
.removeLayer(this._popup)
|
||||
.fire('popupclose', {popup: this._popup});
|
||||
|
||||
this._popup = null;
|
||||
this._popup._close();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -2874,6 +2853,14 @@ L.FeatureGroup = L.LayerGroup.extend({
|
||||
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) {
|
||||
var events = ['click', 'dblclick', 'mouseover', 'mouseout'],
|
||||
i, len;
|
||||
@ -3728,7 +3715,7 @@ L.Polyline = L.Path.extend({
|
||||
},
|
||||
|
||||
_initEvents: function () {
|
||||
L.Polyline.superclass._initEvents.call(this);
|
||||
L.Path.prototype._initEvents.call(this);
|
||||
},
|
||||
|
||||
_getPathPartStr: function (points) {
|
||||
@ -4648,10 +4635,15 @@ L.Handler = L.Class.extend({
|
||||
|
||||
L.Map.mergeOptions({
|
||||
dragging: true,
|
||||
|
||||
inertia: !L.Browser.android,
|
||||
inertiaDeceleration: L.Browser.touch ? 3000 : 2000, // px/s^2
|
||||
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({
|
||||
@ -4727,7 +4719,7 @@ L.Map.Drag = L.Handler.extend({
|
||||
|
||||
_onPreDrag: function () {
|
||||
var map = this._map,
|
||||
worldWidth = map.options.scale(map.getZoom()),
|
||||
worldWidth = map.options.crs.scale(map.getZoom()),
|
||||
halfWidth = Math.round(worldWidth / 2),
|
||||
dx = this._initialWorldOffset.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.
|
||||
@ -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.
|
||||
@ -4870,6 +4864,7 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
|
||||
}
|
||||
});
|
||||
|
||||
L.Map.addInitHook('addHandler', 'scrollWheelZoom', L.Map.ScrollWheelZoom);
|
||||
|
||||
L.Util.extend(L.DomEvent, {
|
||||
// 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).
|
||||
@ -5055,6 +5051,8 @@ L.Map.BoxZoom = L.Handler.extend({
|
||||
.addListener(document, 'mousemove', this._onMouseMove, this)
|
||||
.addListener(document, 'mouseup', this._onMouseUp, this)
|
||||
.preventDefault(e);
|
||||
|
||||
this._map.fire("boxzoomstart");
|
||||
},
|
||||
|
||||
_onMouseMove: function (e) {
|
||||
@ -5093,9 +5091,15 @@ L.Map.BoxZoom = L.Handler.extend({
|
||||
map.layerPointToLatLng(layerPoint));
|
||||
|
||||
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.
|
||||
@ -5179,6 +5183,8 @@ L.Handler.PolyEdit = L.Handler.extend({
|
||||
removeHooks: function () {
|
||||
if (this._poly._map) {
|
||||
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) {
|
||||
var latlng = this._getMiddleLatLng(marker1, marker2),
|
||||
marker = this._createMarker(latlng);
|
||||
marker = this._createMarker(latlng),
|
||||
onClick,
|
||||
onDragStart,
|
||||
onDragEnd;
|
||||
|
||||
marker.setOpacity(0.6);
|
||||
|
||||
marker1._middleRight = marker2._middleLeft = marker;
|
||||
|
||||
function onDragStart() {
|
||||
onDragStart = function () {
|
||||
var i = marker2._index;
|
||||
|
||||
marker._index = i;
|
||||
@ -5317,21 +5326,21 @@ L.Handler.PolyEdit = L.Handler.extend({
|
||||
marker2._index++;
|
||||
this._updatePrevNext(marker1, marker);
|
||||
this._updatePrevNext(marker, marker2);
|
||||
}
|
||||
};
|
||||
|
||||
function onDragEnd() {
|
||||
onDragEnd = function () {
|
||||
marker.off('dragstart', onDragStart, this);
|
||||
marker.off('dragend', onDragEnd, this);
|
||||
|
||||
this._createMiddleMarker(marker1, marker);
|
||||
this._createMiddleMarker(marker, marker2);
|
||||
}
|
||||
};
|
||||
|
||||
function onClick() {
|
||||
onClick = function () {
|
||||
onDragStart.call(this);
|
||||
onDragEnd.call(this);
|
||||
this._poly.fire('edit');
|
||||
}
|
||||
};
|
||||
|
||||
marker
|
||||
.on('click', onClick, this)
|
||||
@ -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({
|
||||
options: {
|
||||
@ -5489,16 +5508,25 @@ L.Control.Attribution = L.Control.extend({
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
this._map = map;
|
||||
|
||||
this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
|
||||
L.DomEvent.disableClickPropagation(this._container);
|
||||
|
||||
map
|
||||
.on('layeradd', this._onLayerAdd, this)
|
||||
.on('layerremove', this._onLayerRemove, this);
|
||||
|
||||
this._update();
|
||||
|
||||
return this._container;
|
||||
},
|
||||
|
||||
onRemove: function (map) {
|
||||
map
|
||||
.off('layeradd', this._onLayerAdd)
|
||||
.off('layerremove', this._onLayerRemove);
|
||||
|
||||
},
|
||||
|
||||
setPrefix: function (prefix) {
|
||||
this.options.prefix = prefix;
|
||||
this._update();
|
||||
@ -5543,9 +5571,30 @@ L.Control.Attribution = L.Control.extend({
|
||||
}
|
||||
|
||||
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({
|
||||
options: {
|
||||
@ -6075,6 +6124,7 @@ L.Transition = L.Transition.NATIVE ? L.Transition : L.Transition.extend({
|
||||
});
|
||||
|
||||
|
||||
|
||||
L.Map.include(!(L.Transition && L.Transition.implemented()) ? {} : {
|
||||
setView: function (center, zoom, forceReset) {
|
||||
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 ? {} : {
|
||||
_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();
|
||||
});
|
||||
|
||||
/* superclass deprecated
|
||||
it("should grant the ability to call parent methods, including constructor", function() {
|
||||
var Klass2 = Klass.extend({
|
||||
initialize: function() {},
|
||||
@ -60,7 +61,7 @@ describe("Class", function() {
|
||||
|
||||
b.constructor.superclass.bar.call(this);
|
||||
expect(method).toHaveBeenCalled();
|
||||
});
|
||||
}); */
|
||||
|
||||
it("should support static properties", function() {
|
||||
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() {
|
||||
var constructor2 = jasmine.createSpy("Klass2 constructor"),
|
||||
constructor3 = jasmine.createSpy("Klass3 constructor");
|
||||
@ -149,5 +151,6 @@ describe("Class", function() {
|
||||
expect(constructor2).toHaveBeenCalled();
|
||||
expect(constructor).toHaveBeenCalled();
|
||||
});
|
||||
*/
|
||||
});
|
||||
});
|
@ -104,7 +104,7 @@ L.Polyline = L.Path.extend({
|
||||
},
|
||||
|
||||
_initEvents: function () {
|
||||
L.Polyline.superclass._initEvents.call(this);
|
||||
L.Path.prototype._initEvents.call(this);
|
||||
},
|
||||
|
||||
_getPathPartStr: function (points) {
|
||||
|
Loading…
Reference in New Issue
Block a user