update build

This commit is contained in:
Vladimir Agafonkin 2013-04-22 17:08:19 +03:00
parent eafa54635b
commit 2ec3dc57c0
2 changed files with 188 additions and 222 deletions

402
dist/leaflet-src.js vendored
View File

@ -68,9 +68,7 @@ L.Util = {
args = Array.prototype.slice.call(arguments, 3); args = Array.prototype.slice.call(arguments, 3);
for (i in obj) { for (i in obj) {
if (obj.hasOwnProperty(i)) { method.apply(context, [i, obj[i]].concat(args));
method.apply(context, [i, obj[i]].concat(args));
}
} }
return true; return true;
} }
@ -113,8 +111,12 @@ L.Util = {
return Math.round(num * pow) / pow; return Math.round(num * pow) / pow;
}, },
trim: function (str) {
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
},
splitWords: function (str) { splitWords: function (str) {
return str.replace(/^\s+|\s+$/g, '').split(/\s+/); return L.Util.trim(str).split(/\s+/);
}, },
setOptions: function (obj, options) { setOptions: function (obj, options) {
@ -125,9 +127,7 @@ L.Util = {
getParamString: function (obj, existingUrl) { getParamString: function (obj, existingUrl) {
var params = []; var params = [];
for (var i in obj) { for (var i in obj) {
if (obj.hasOwnProperty(i)) { params.push(encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]));
params.push(encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]));
}
} }
return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&'); return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');
}, },
@ -135,7 +135,7 @@ L.Util = {
template: function (str, data) { template: function (str, data) {
return str.replace(/\{ *([\w_]+) *\}/g, function (str, key) { return str.replace(/\{ *([\w_]+) *\}/g, function (str, key) {
var value = data[key]; var value = data[key];
if (!data.hasOwnProperty(key)) { if (value === undefined) {
throw new Error('No value provided for variable ' + str); throw new Error('No value provided for variable ' + str);
} else if (typeof value === 'function') { } else if (typeof value === 'function') {
value = value(data); value = value(data);
@ -456,13 +456,11 @@ L.Mixin.Events = {
typeIndex = events[type + '_idx']; typeIndex = events[type + '_idx'];
for (contextId in typeIndex) { for (contextId in typeIndex) {
if (typeIndex.hasOwnProperty(contextId)) { listeners = typeIndex[contextId];
listeners = typeIndex[contextId];
if (listeners) { if (listeners) {
for (i = 0, len = listeners.length; i < len; i++) { for (i = 0, len = listeners.length; i < len; i++) {
listeners[i].action.call(listeners[i].context || this, event); listeners[i].action.call(listeners[i].context || this, event);
}
} }
} }
} }
@ -969,15 +967,7 @@ L.DomUtil = {
}, },
removeClass: function (el, name) { removeClass: function (el, name) {
el.className = L.Util.trim((' ' + el.className + ' ').replace(' ' + name + ' ', ' '));
function replaceFn(w, match) {
if (match === name) { return ''; }
return w;
}
el.className = el.className
.replace(/(\S+)\s*/g, replaceFn)
.replace(/(^\s+|\s+$)/, '');
}, },
setOpacity: function (el, value) { setOpacity: function (el, value) {
@ -1533,22 +1523,28 @@ L.Map = L.Class.extend({
return this.setView(newCenter, zoom); return this.setView(newCenter, zoom);
}, },
fitBounds: function (bounds) { // (LatLngBounds) fitBounds: function (bounds, paddingTopLeft, paddingBottomRight) { // (LatLngBounds || ILayer[, Point, Point])
bounds = L.latLngBounds(bounds);
var zoom = this.getBoundsZoom(bounds), bounds = bounds.getBounds ? bounds.getBounds() : L.latLngBounds(bounds);
swPoint = this.project(bounds.getSouthWest()),
nePoint = this.project(bounds.getNorthEast()), paddingTopLeft = L.point(paddingTopLeft || [0, 0]);
center = this.unproject(swPoint.add(nePoint).divideBy(2)); paddingBottomRight = L.point(paddingBottomRight || paddingTopLeft);
var zoom = this.getBoundsZoom(bounds, false, paddingTopLeft.add(paddingBottomRight)),
paddingOffset = new L.Point(
paddingBottomRight.x - paddingTopLeft.x,
paddingBottomRight.y - paddingTopLeft.y).divideBy(2),
swPoint = this.project(bounds.getSouthWest(), zoom),
nePoint = this.project(bounds.getNorthEast(), zoom),
center = this.unproject(swPoint.add(nePoint).divideBy(2).add(paddingOffset), zoom);
return this.setView(center, zoom); return this.setView(center, zoom);
}, },
fitWorld: function () { fitWorld: function () {
var sw = new L.LatLng(-60, -170), return this.fitBounds([[-90, -180], [90, 180]]);
ne = new L.LatLng(85, 179);
return this.fitBounds(new L.LatLngBounds(sw, ne));
}, },
panTo: function (center) { // (LatLng) panTo: function (center) { // (LatLng)
@ -1679,15 +1675,12 @@ L.Map = L.Class.extend({
hasLayer: function (layer) { hasLayer: function (layer) {
if (!layer) { return false; } if (!layer) { return false; }
var id = L.stamp(layer); return (L.stamp(layer) in this);
return this._layers.hasOwnProperty(id);
}, },
eachLayer: function (method, context) { eachLayer: function (method, context) {
for (var i in this._layers) { for (var i in this._layers) {
if (this._layers.hasOwnProperty(i)) { method.call(context, this._layers[i]);
method.call(context, this._layers[i]);
}
} }
return this; return this;
}, },
@ -1786,37 +1779,26 @@ L.Map = L.Class.extend({
return Math.min(z1, z2); return Math.min(z1, z2);
}, },
getBoundsZoom: function (bounds, inside) { // (LatLngBounds, Boolean) -> Number getBoundsZoom: function (bounds, inside, padding) { // (LatLngBounds[, Boolean, Point]) -> Number
bounds = L.latLngBounds(bounds); bounds = L.latLngBounds(bounds);
var size = this.getSize(), var zoom = this.getMinZoom() - (inside ? 1 : 0),
zoom = this.options.minZoom || 0,
maxZoom = this.getMaxZoom(), maxZoom = this.getMaxZoom(),
ne = bounds.getNorthEast(), size = this.getSize(),
sw = bounds.getSouthWest(),
boundsSize,
nePoint,
swPoint,
zoomNotFound = true;
if (inside) { nw = bounds.getNorthWest(),
zoom--; se = bounds.getSouthEast(),
}
zoomNotFound = true,
boundsSize;
padding = L.point(padding || [0, 0]);
do { do {
zoom++; zoom++;
nePoint = this.project(ne, zoom); boundsSize = this.project(se, zoom).subtract(this.project(nw, zoom)).add(padding);
swPoint = this.project(sw, zoom); zoomNotFound = !inside ? size.contains(boundsSize) : boundsSize.x < size.x || boundsSize.y < size.y;
boundsSize = new L.Point(
Math.abs(nePoint.x - swPoint.x),
Math.abs(swPoint.y - nePoint.y));
if (!inside) {
zoomNotFound = boundsSize.x <= size.x && boundsSize.y <= size.y;
} else {
zoomNotFound = boundsSize.x < size.x || boundsSize.y < size.y;
}
} while (zoomNotFound && zoom <= maxZoom); } while (zoomNotFound && zoom <= maxZoom);
if (zoomNotFound && inside) { if (zoomNotFound && inside) {
@ -2030,6 +2012,10 @@ L.Map = L.Class.extend({
var loading = !this._loaded; var loading = !this._loaded;
this._loaded = true; this._loaded = true;
if (loading) {
this.fire('load');
}
this.fire('viewreset', {hard: !preserveMapOffset}); this.fire('viewreset', {hard: !preserveMapOffset});
this.fire('move'); this.fire('move');
@ -2039,10 +2025,6 @@ L.Map = L.Class.extend({
} }
this.fire('moveend', {hard: !preserveMapOffset}); this.fire('moveend', {hard: !preserveMapOffset});
if (loading) {
this.fire('load');
}
}, },
_rawPanBy: function (offset) { _rawPanBy: function (offset) {
@ -2060,14 +2042,12 @@ L.Map = L.Class.extend({
oldZoomSpan = this._getZoomSpan(); oldZoomSpan = this._getZoomSpan();
for (i in this._zoomBoundLayers) { for (i in this._zoomBoundLayers) {
if (this._zoomBoundLayers.hasOwnProperty(i)) { var layer = this._zoomBoundLayers[i];
var layer = this._zoomBoundLayers[i]; if (!isNaN(layer.options.minZoom)) {
if (!isNaN(layer.options.minZoom)) { minZoom = Math.min(minZoom, layer.options.minZoom);
minZoom = Math.min(minZoom, layer.options.minZoom); }
} if (!isNaN(layer.options.maxZoom)) {
if (!isNaN(layer.options.maxZoom)) { maxZoom = Math.max(maxZoom, layer.options.maxZoom);
maxZoom = Math.max(maxZoom, layer.options.maxZoom);
}
} }
} }
@ -2509,9 +2489,7 @@ L.TileLayer = L.Class.extend({
if (L.Browser.ielt9) { if (L.Browser.ielt9) {
for (i in tiles) { for (i in tiles) {
if (tiles.hasOwnProperty(i)) { L.DomUtil.setOpacity(tiles[i], this.options.opacity);
L.DomUtil.setOpacity(tiles[i], this.options.opacity);
}
} }
} else { } else {
L.DomUtil.setOpacity(this._container, this.options.opacity); L.DomUtil.setOpacity(this._container, this.options.opacity);
@ -2520,9 +2498,7 @@ L.TileLayer = L.Class.extend({
// stupid webkit hack to force redrawing of tiles // stupid webkit hack to force redrawing of tiles
if (L.Browser.webkit) { if (L.Browser.webkit) {
for (i in tiles) { for (i in tiles) {
if (tiles.hasOwnProperty(i)) { tiles[i].style.webkitTransform += ' translate(0,0)';
tiles[i].style.webkitTransform += ' translate(0,0)';
}
} }
} }
}, },
@ -2553,12 +2529,8 @@ L.TileLayer = L.Class.extend({
}, },
_reset: function (e) { _reset: function (e) {
var tiles = this._tiles; for (var key in this._tiles) {
this.fire('tileunload', {tile: this._tiles[key]});
for (var key in tiles) {
if (tiles.hasOwnProperty(key)) {
this.fire('tileunload', {tile: tiles[key]});
}
} }
this._tiles = {}; this._tiles = {};
@ -2681,15 +2653,13 @@ L.TileLayer = L.Class.extend({
var kArr, x, y, key; var kArr, x, y, key;
for (key in this._tiles) { for (key in this._tiles) {
if (this._tiles.hasOwnProperty(key)) { kArr = key.split(':');
kArr = key.split(':'); x = parseInt(kArr[0], 10);
x = parseInt(kArr[0], 10); y = parseInt(kArr[1], 10);
y = parseInt(kArr[1], 10);
// remove tile if it's out of bounds // remove tile if it's out of bounds
if (x < bounds.min.x || x > bounds.max.x || y < bounds.min.y || y > bounds.max.y) { if (x < bounds.min.x || x > bounds.max.x || y < bounds.min.y || y > bounds.max.y) {
this._removeTile(key); this._removeTile(key);
}
} }
} }
}, },
@ -2984,12 +2954,8 @@ L.TileLayer.Canvas = L.TileLayer.extend({
}, },
redraw: function () { redraw: function () {
var tiles = this._tiles; for (var i in this._tiles) {
this._redrawTile(this._tiles[i]);
for (var i in tiles) {
if (tiles.hasOwnProperty(i)) {
this._redrawTile(tiles[i]);
}
} }
return this; return this;
}, },
@ -3663,6 +3629,7 @@ L.Popup = L.Class.extend({
closeButton: true, closeButton: true,
offset: new L.Point(0, 6), offset: new L.Point(0, 6),
autoPanPadding: new L.Point(5, 5), autoPanPadding: new L.Point(5, 5),
keepInView: false,
className: '', className: '',
zoomAnimation: true zoomAnimation: true
}, },
@ -3689,21 +3656,21 @@ L.Popup = L.Class.extend({
} }
map._panes.popupPane.appendChild(this._container); map._panes.popupPane.appendChild(this._container);
map.on('viewreset', this._updatePosition, this); map.on(this._getEvents(), this);
if (this._animated) {
map.on('zoomanim', this._zoomAnimation, this);
}
if (map.options.closePopupOnClick) {
map.on('preclick', this._close, this);
}
this._update(); this._update();
if (animFade) { if (animFade) {
L.DomUtil.setOpacity(this._container, 1); L.DomUtil.setOpacity(this._container, 1);
} }
this.fire('open');
map.fire('popupopen', {popup: this});
if (this._source) {
this._source.fire('popupopen', {popup: this});
}
}, },
addTo: function (map) { addTo: function (map) {
@ -3721,17 +3688,21 @@ L.Popup = L.Class.extend({
L.Util.falseFn(this._container.offsetWidth); // force reflow L.Util.falseFn(this._container.offsetWidth); // force reflow
map.off({ map.off(this._getEvents(), this);
viewreset: this._updatePosition,
preclick: this._close,
zoomanim: this._zoomAnimation
}, this);
if (map.options.fadeAnimation) { if (map.options.fadeAnimation) {
L.DomUtil.setOpacity(this._container, 0); L.DomUtil.setOpacity(this._container, 0);
} }
this._map = null; this._map = null;
this.fire('close');
map.fire('popupclose', {popup: this});
if (this._source) {
this._source.fire('popupclose', {popup: this});
}
}, },
setLatLng: function (latlng) { setLatLng: function (latlng) {
@ -3746,15 +3717,27 @@ L.Popup = L.Class.extend({
return this; return this;
}, },
_getEvents: function () {
var events = {
viewreset: this._updatePosition
};
if (this._animated) {
events.zoomanim = this._zoomAnimation;
}
if (this._map.options.closePopupOnClick) {
events.preclick = this._close;
}
if (this.options.keepInView) {
events.moveend = this._adjustPan;
}
return events;
},
_close: function () { _close: function () {
var map = this._map; if (this._map) {
this._map.removeLayer(this);
if (map) {
map._popup = null;
map
.removeLayer(this)
.fire('popupclose', {popup: this});
} }
}, },
@ -3858,7 +3841,7 @@ L.Popup = L.Class.extend({
this._containerBottom = -offset.y - (animated ? 0 : pos.y); this._containerBottom = -offset.y - (animated ? 0 : pos.y);
this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x + (animated ? 0 : pos.x); this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x + (animated ? 0 : pos.x);
//Bottom position the popup in case the height of the popup changes (images loading etc) // bottom position the popup in case the height of the popup changes (images loading etc)
this._container.style.bottom = this._containerBottom + 'px'; this._container.style.bottom = this._containerBottom + 'px';
this._container.style.left = this._containerLeft + 'px'; this._container.style.left = this._containerLeft + 'px';
}, },
@ -3888,18 +3871,18 @@ L.Popup = L.Class.extend({
dx = 0, dx = 0,
dy = 0; dy = 0;
if (containerPos.x < 0) { if (containerPos.x + containerWidth > size.x) { // right
dx = containerPos.x - padding.x;
}
if (containerPos.x + containerWidth > size.x) {
dx = containerPos.x + containerWidth - size.x + padding.x; dx = containerPos.x + containerWidth - size.x + padding.x;
} }
if (containerPos.y < 0) { if (containerPos.x - dx < 0) { // left
dy = containerPos.y - padding.y; dx = containerPos.x - padding.x;
} }
if (containerPos.y + containerHeight > size.y) { if (containerPos.y + containerHeight > size.y) { // bottom
dy = containerPos.y + containerHeight - size.y + padding.y; dy = containerPos.y + containerHeight - size.y + padding.y;
} }
if (containerPos.y - dy < 0) { // top
dy = containerPos.y - padding.y;
}
if (dx || dy) { if (dx || dy) {
map map
@ -3919,6 +3902,32 @@ L.popup = function (options, source) {
}; };
L.Map.include({
openPopup: function (popup, latlng, options) { // (Popup) or (String || HTMLElement, LatLng[, Object])
this.closePopup();
if (!(popup instanceof L.Popup)) {
var content = popup;
popup = new L.Popup(options)
.setLatLng(latlng)
.setContent(content);
}
this._popup = popup;
return this.addLayer(popup);
},
closePopup: function () {
if (this._popup) {
this.removeLayer(this._popup);
this._popup = null;
}
return this;
}
});
/* /*
* Popup extension to L.Marker, adding popup-related methods. * Popup extension to L.Marker, adding popup-related methods.
*/ */
@ -3993,30 +4002,6 @@ L.Marker.include({
}); });
/*
* Adds popup-related methods to L.Map.
*/
L.Map.include({
openPopup: function (popup) {
this.closePopup();
this._popup = popup;
return this
.addLayer(popup)
.fire('popupopen', {popup: this._popup});
},
closePopup: function () {
if (this._popup) {
this._popup._close();
}
return this;
}
});
/* /*
* L.LayerGroup is a class to combine several layers into one so that * L.LayerGroup is a class to combine several layers into one so that
* you can manipulate the group (e.g. add/remove it) as one layer. * you can manipulate the group (e.g. add/remove it) as one layer.
@ -4062,8 +4047,7 @@ L.LayerGroup = L.Class.extend({
hasLayer: function (layer) { hasLayer: function (layer) {
if (!layer) { return false; } if (!layer) { return false; }
var id = this.getLayerId(layer); return (this.getLayerId(layer) in this._layers);
return this._layers.hasOwnProperty(id);
}, },
clearLayers: function () { clearLayers: function () {
@ -4076,12 +4060,10 @@ L.LayerGroup = L.Class.extend({
i, layer; i, layer;
for (i in this._layers) { for (i in this._layers) {
if (this._layers.hasOwnProperty(i)) { layer = this._layers[i];
layer = this._layers[i];
if (layer[methodName]) { if (layer[methodName]) {
layer[methodName].apply(layer, args); layer[methodName].apply(layer, args);
}
} }
} }
@ -4105,9 +4087,7 @@ L.LayerGroup = L.Class.extend({
eachLayer: function (method, context) { eachLayer: function (method, context) {
for (var i in this._layers) { for (var i in this._layers) {
if (this._layers.hasOwnProperty(i)) { method.call(context, this._layers[i]);
method.call(context, this._layers[i]);
}
} }
return this; return this;
}, },
@ -4115,9 +4095,7 @@ L.LayerGroup = L.Class.extend({
getLayers: function () { getLayers: function () {
var layers = []; var layers = [];
for (var i in this._layers) { for (var i in this._layers) {
if (this._layers.hasOwnProperty(i)) { layers.push(this._layers[i]);
layers.push(this._layers[i]);
}
} }
return layers; return layers;
}, },
@ -4704,7 +4682,7 @@ L.Path = L.Browser.svg || !L.Browser.vml ? L.Path : L.Path.extend({
if (options.dashArray) { if (options.dashArray) {
stroke.dashStyle = options.dashArray instanceof Array ? stroke.dashStyle = options.dashArray instanceof Array ?
options.dashArray.join(' ') : options.dashArray.join(' ') :
options.dashArray.replace(/ *, */g, ' '); options.dashArray.replace(/( *, *)/g, ' ');
} else { } else {
stroke.dashStyle = ''; stroke.dashStyle = '';
} }
@ -5805,7 +5783,7 @@ L.GeoJSON = L.FeatureGroup.extend({
if (options.filter && !options.filter(geojson)) { return; } if (options.filter && !options.filter(geojson)) { return; }
var layer = L.GeoJSON.geometryToLayer(geojson, options.pointToLayer); var layer = L.GeoJSON.geometryToLayer(geojson, options.pointToLayer, options.coordsToLatLng);
layer.feature = geojson; layer.feature = geojson;
layer.defaultOptions = layer.options; layer.defaultOptions = layer.options;
@ -5845,48 +5823,52 @@ L.GeoJSON = L.FeatureGroup.extend({
}); });
L.extend(L.GeoJSON, { L.extend(L.GeoJSON, {
geometryToLayer: function (geojson, pointToLayer) { geometryToLayer: function (geojson, pointToLayer, coordsToLatLng) {
var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson, var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson,
coords = geometry.coordinates, coords = geometry.coordinates,
layers = [], layers = [],
latlng, latlngs, i, len, layer; latlng, latlngs, i, len, layer;
coordsToLatLng = coordsToLatLng || this.coordsToLatLng;
switch (geometry.type) { switch (geometry.type) {
case 'Point': case 'Point':
latlng = this.coordsToLatLng(coords); latlng = coordsToLatLng(coords);
return pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng); return pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng);
case 'MultiPoint': case 'MultiPoint':
for (i = 0, len = coords.length; i < len; i++) { for (i = 0, len = coords.length; i < len; i++) {
latlng = this.coordsToLatLng(coords[i]); latlng = coordsToLatLng(coords[i]);
layer = pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng); layer = pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng);
layers.push(layer); layers.push(layer);
} }
return new L.FeatureGroup(layers); return new L.FeatureGroup(layers);
case 'LineString': case 'LineString':
latlngs = this.coordsToLatLngs(coords); latlngs = this.coordsToLatLngs(coords, 0, coordsToLatLng);
return new L.Polyline(latlngs); return new L.Polyline(latlngs);
case 'Polygon': case 'Polygon':
latlngs = this.coordsToLatLngs(coords, 1); latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng);
return new L.Polygon(latlngs); return new L.Polygon(latlngs);
case 'MultiLineString': case 'MultiLineString':
latlngs = this.coordsToLatLngs(coords, 1); latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng);
return new L.MultiPolyline(latlngs); return new L.MultiPolyline(latlngs);
case 'MultiPolygon': case 'MultiPolygon':
latlngs = this.coordsToLatLngs(coords, 2); latlngs = this.coordsToLatLngs(coords, 2, coordsToLatLng);
return new L.MultiPolygon(latlngs); return new L.MultiPolygon(latlngs);
case 'GeometryCollection': case 'GeometryCollection':
for (i = 0, len = geometry.geometries.length; i < len; i++) { for (i = 0, len = geometry.geometries.length; i < len; i++) {
layer = this.geometryToLayer({ layer = this.geometryToLayer({
geometry: geometry.geometries[i], geometry: geometry.geometries[i],
type: 'Feature', type: 'Feature',
properties: geojson.properties properties: geojson.properties
}, pointToLayer); }, pointToLayer);
layers.push(layer); layers.push(layer);
} }
return new L.FeatureGroup(layers); return new L.FeatureGroup(layers);
@ -5896,40 +5878,33 @@ L.extend(L.GeoJSON, {
} }
}, },
coordsToLatLng: function (coords, reverse) { // (Array, Boolean) -> LatLng coordsToLatLng: function (coords) { // (Array[, Boolean]) -> LatLng
var lat = parseFloat(coords[reverse ? 0 : 1]), return new L.LatLng(coords[1], coords[0]);
lng = parseFloat(coords[reverse ? 1 : 0]);
return new L.LatLng(lat, lng);
}, },
coordsToLatLngs: function (coords, levelsDeep, reverse) { // (Array, Number, Boolean) -> Array coordsToLatLngs: function (coords, levelsDeep, coordsToLatLng) { // (Array[, Number, Function]) -> Array
var latlng, var latlng, i, len,
latlngs = [], latlngs = [];
i, len;
for (i = 0, len = coords.length; i < len; i++) { for (i = 0, len = coords.length; i < len; i++) {
latlng = levelsDeep ? latlng = levelsDeep ?
this.coordsToLatLngs(coords[i], levelsDeep - 1, reverse) : this.coordsToLatLngs(coords[i], levelsDeep - 1, coordsToLatLng) :
this.coordsToLatLng(coords[i], reverse); (coordsToLatLng || this.coordsToLatLng)(coords[i]);
latlngs.push(latlng); latlngs.push(latlng);
} }
return latlngs; return latlngs;
} },
});
L.extend(L.GeoJSON, {
latLngToCoords: function (latLng) { latLngToCoords: function (latLng) {
return [latLng.lng, latLng.lat]; return [latLng.lng, latLng.lat];
}, },
latLngsToCoords: function (latLngs) { latLngsToCoords: function (latLngs) {
var coords = [], var coords = [];
i, len;
for (i = 0, len = latLngs.length; i < len; i++) { for (var i = 0, len = latLngs.length; i < len; i++) {
coords.push(L.GeoJSON.latLngToCoords(latLngs[i])); coords.push(L.GeoJSON.latLngToCoords(latLngs[i]));
} }
@ -6400,11 +6375,9 @@ L.Draggable = L.Class.extend({
} }
for (i in L.Draggable.MOVE) { for (i in L.Draggable.MOVE) {
if (L.Draggable.MOVE.hasOwnProperty(i)) { L.DomEvent
L.DomEvent .off(document, L.Draggable.MOVE[i], this._onMove)
.off(document, L.Draggable.MOVE[i], this._onMove) .off(document, L.Draggable.END[i], this._onUp);
.off(document, L.Draggable.END[i], this._onUp);
}
} }
if (this._moved) { if (this._moved) {
@ -7300,14 +7273,14 @@ L.Map.Keyboard = L.Handler.extend({
var key = e.keyCode, var key = e.keyCode,
map = this._map; map = this._map;
if (this._panKeys.hasOwnProperty(key)) { if (key in this._panKeys) {
map.panBy(this._panKeys[key]); map.panBy(this._panKeys[key]);
if (map.options.maxBounds) { if (map.options.maxBounds) {
map.panInsideBounds(map.options.maxBounds); map.panInsideBounds(map.options.maxBounds);
} }
} else if (this._zoomKeys.hasOwnProperty(key)) { } else if (key in this._zoomKeys) {
map.setZoom(map.getZoom() + this._zoomKeys[key]); map.setZoom(map.getZoom() + this._zoomKeys[key]);
} else { } else {
@ -7465,9 +7438,7 @@ L.control = function (options) {
}; };
/* // adds control-related methods to L.Map
* Adds control-related methods to L.Map.
*/
L.Map.include({ L.Map.include({
addControl: function (control) { addControl: function (control) {
@ -7660,7 +7631,7 @@ L.Control.Attribution = L.Control.extend({
var attribs = []; var attribs = [];
for (var i in this._attributions) { for (var i in this._attributions) {
if (this._attributions.hasOwnProperty(i) && this._attributions[i]) { if (this._attributions[i]) {
attribs.push(i); attribs.push(i);
} }
} }
@ -7838,15 +7809,11 @@ L.Control.Layers = L.Control.extend({
this._handlingClick = false; this._handlingClick = false;
for (var i in baseLayers) { for (var i in baseLayers) {
if (baseLayers.hasOwnProperty(i)) { this._addLayer(baseLayers[i], i);
this._addLayer(baseLayers[i], i);
}
} }
for (i in overlays) { for (i in overlays) {
if (overlays.hasOwnProperty(i)) { this._addLayer(overlays[i], i, true);
this._addLayer(overlays[i], i, true);
}
} }
}, },
@ -7955,18 +7922,17 @@ L.Control.Layers = L.Control.extend({
this._overlaysList.innerHTML = ''; this._overlaysList.innerHTML = '';
var baseLayersPresent = false, var baseLayersPresent = false,
overlaysPresent = false; overlaysPresent = false,
i, obj;
for (var i in this._layers) { for (i in this._layers) {
if (this._layers.hasOwnProperty(i)) { obj = this._layers[i];
var obj = this._layers[i]; this._addItem(obj);
this._addItem(obj); overlaysPresent = overlaysPresent || obj.overlay;
overlaysPresent = overlaysPresent || obj.overlay; baseLayersPresent = baseLayersPresent || !obj.overlay;
baseLayersPresent = baseLayersPresent || !obj.overlay;
}
} }
this._separator.style.display = (overlaysPresent && baseLayersPresent ? '' : 'none'); this._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none';
}, },
_onLayerChange: function (e) { _onLayerChange: function (e) {

8
dist/leaflet.js vendored

File diff suppressed because one or more lines are too long