Skip to content

Commit e87e010

Browse files
committed
update changelog and build
1 parent 3cc75db commit e87e010

File tree

3 files changed

+50
-17
lines changed

3 files changed

+50
-17
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ An in-progress version being developed on the master branch.
7474
* Fixed a bug where layers that belong to multiple feature groups didn't propagate events correctly (by [@danzel](https://github.com/danzel)). [#1359](https://github.com/Leaflet/Leaflet/pull/1359)
7575
* Fixed a bug where `Control.Attribution` `removeAttribution` of inexistant attribution corrupted the attribution text. [#1410](https://github.com/Leaflet/Leaflet/issues/1410)
7676
* Fixed a bug where `TileLayer.WMS` `tileSize` option was ignored (by [@brianhatchl](https://github.com/brianhatchl)). [#1080](https://github.com/brianhatchl)
77+
* Fixed a bug where `Polyline` constructor could overwrite the source array (by [@snkashis](https://github.com/snkashis) and [@danzel](https://github.com/danzel)). [#1439](https://github.com/Leaflet/Leaflet/pull/1439) [#1092](https://github.com/Leaflet/Leaflet/issues/1092) [#1246](https://github.com/Leaflet/Leaflet/issues/1246) [#1426](https://github.com/Leaflet/Leaflet/issues/1426)
7778

7879
## 0.5.1 (February 6, 2013)
7980

dist/leaflet-src.js

+45-13
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,11 @@ L.Map = L.Class.extend({
16571657
// public methods for getting map state
16581658

16591659
getCenter: function () { // (Boolean) -> LatLng
1660+
this._checkIfLoaded();
1661+
1662+
if (!this._moved()) {
1663+
return this._initialCenter;
1664+
}
16601665
return this.layerPointToLatLng(this._getCenterLayerPoint());
16611666
},
16621667

@@ -1744,9 +1749,7 @@ L.Map = L.Class.extend({
17441749
},
17451750

17461751
getPixelOrigin: function () {
1747-
if (!this._loaded) {
1748-
throw new Error('Set map center and zoom first.');
1749-
}
1752+
this._checkIfLoaded();
17501753
return this._initialTopLeftPoint;
17511754
},
17521755

@@ -1916,6 +1919,7 @@ L.Map = L.Class.extend({
19161919
}
19171920

19181921
this._zoom = zoom;
1922+
this._initialCenter = center;
19191923

19201924
this._initialTopLeftPoint = this._getNewTopLeftPoint(center);
19211925

@@ -1983,6 +1987,12 @@ L.Map = L.Class.extend({
19831987
}
19841988
},
19851989

1990+
_checkIfLoaded: function () {
1991+
if (!this._loaded) {
1992+
throw new Error('Set map center and zoom first.');
1993+
}
1994+
},
1995+
19861996
// map events
19871997

19881998
_initEvents: function (onOff) {
@@ -2066,6 +2076,11 @@ L.Map = L.Class.extend({
20662076
return L.DomUtil.getPosition(this._mapPane);
20672077
},
20682078

2079+
_moved: function () {
2080+
var pos = this._getMapPanePos();
2081+
return pos && !pos.equals(new L.Point(0, 0));
2082+
},
2083+
20692084
_getTopLeftPoint: function () {
20702085
return this.getPixelOrigin().subtract(this._getMapPanePos());
20712086
},
@@ -2702,9 +2717,11 @@ L.TileLayer = L.Class.extend({
27022717
if (!this._tilesToLoad) {
27032718
this.fire('load');
27042719

2705-
// clear scaled tiles after all new tiles are loaded (for performance)
2706-
clearTimeout(this._clearBgBufferTimer);
2707-
this._clearBgBufferTimer = setTimeout(L.bind(this._clearBgBuffer, this), 500);
2720+
if (this._animated) {
2721+
// clear scaled tiles after all new tiles are loaded (for performance)
2722+
clearTimeout(this._clearBgBufferTimer);
2723+
this._clearBgBufferTimer = setTimeout(L.bind(this._clearBgBuffer, this), 500);
2724+
}
27082725
}
27092726
},
27102727

@@ -5032,7 +5049,7 @@ L.Polyline = L.Path.extend({
50325049

50335050
spliceLatLngs: function () { // (Number index, Number howMany)
50345051
var removed = [].splice.apply(this._latlngs, arguments);
5035-
this._convertLatLngs(this._latlngs);
5052+
this._convertLatLngs(this._latlngs, true);
50365053
this.redraw();
50375054
return removed;
50385055
},
@@ -5070,15 +5087,16 @@ L.Polyline = L.Path.extend({
50705087
return bounds;
50715088
},
50725089

5073-
_convertLatLngs: function (latlngs) {
5074-
var i, len;
5090+
_convertLatLngs: function (latlngs, overwrite) {
5091+
var i, len, target = overwrite ? latlngs : [];
5092+
50755093
for (i = 0, len = latlngs.length; i < len; i++) {
50765094
if (L.Util.isArray(latlngs[i]) && typeof latlngs[i][0] !== 'number') {
50775095
return;
50785096
}
5079-
latlngs[i] = L.latLng(latlngs[i]);
5097+
target[i] = L.latLng(latlngs[i]);
50805098
}
5081-
return latlngs;
5099+
return target;
50825100
},
50835101

50845102
_initEvents: function () {
@@ -6836,6 +6854,7 @@ L.Map.BoxZoom = L.Handler.extend({
68366854
L.DomEvent
68376855
.on(document, 'mousemove', this._onMouseMove, this)
68386856
.on(document, 'mouseup', this._onMouseUp, this)
6857+
.on(document, 'keydown', this._onKeyDown, this)
68396858
.preventDefault(e);
68406859

68416860
this._map.fire("boxzoomstart");
@@ -6859,15 +6878,21 @@ L.Map.BoxZoom = L.Handler.extend({
68596878
box.style.height = (Math.max(0, Math.abs(offset.y) - 4)) + 'px';
68606879
},
68616880

6862-
_onMouseUp: function (e) {
6881+
_finish: function () {
68636882
this._pane.removeChild(this._box);
68646883
this._container.style.cursor = '';
68656884

68666885
L.DomUtil.enableTextSelection();
68676886

68686887
L.DomEvent
68696888
.off(document, 'mousemove', this._onMouseMove)
6870-
.off(document, 'mouseup', this._onMouseUp);
6889+
.off(document, 'mouseup', this._onMouseUp)
6890+
.off(document, 'keydown', this._onKeyDown);
6891+
},
6892+
6893+
_onMouseUp: function (e) {
6894+
6895+
this._finish();
68716896

68726897
var map = this._map,
68736898
layerPoint = map.mouseEventToLayerPoint(e);
@@ -6883,6 +6908,12 @@ L.Map.BoxZoom = L.Handler.extend({
68836908
map.fire("boxzoomend", {
68846909
boxZoomBounds: bounds
68856910
});
6911+
},
6912+
6913+
_onKeyDown: function (e) {
6914+
if (e.keyCode === 27) {
6915+
this._finish();
6916+
}
68866917
}
68876918
});
68886919

@@ -7857,6 +7888,7 @@ L.Map.include({
78577888

78587889
setView: function (center, zoom, forceReset) {
78597890
zoom = this._limitZoom(zoom);
7891+
center = L.latLng(center);
78607892

78617893
var zoomChanged = (this._zoom !== zoom);
78627894

0 commit comments

Comments
 (0)