Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Polyline/Polygon not overwrite the source array #1439

Merged
merged 4 commits into from
Feb 21, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow overwriting the given array, for usage by spliceLatLngs.
  • Loading branch information
danzel committed Feb 19, 2013
commit 3afee7eb4908971f3db9f7a3d9ff5416be8fb519
8 changes: 4 additions & 4 deletions src/layer/vector/Polyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ L.Polyline = L.Path.extend({

spliceLatLngs: function () { // (Number index, Number howMany)
var removed = [].splice.apply(this._latlngs, arguments);
this._convertLatLngs(this._latlngs);
this._convertLatLngs(this._latlngs, true);
this.redraw();
return removed;
},
Expand Down Expand Up @@ -85,11 +85,11 @@ L.Polyline = L.Path.extend({
return bounds;
},

_convertLatLngs: function (latlngs) {
var i, len, target = [];
_convertLatLngs: function (latlngs, overwrite) {
var i, len, target = overwrite ? latlngs : [];

for (i = 0, len = latlngs.length; i < len; i++) {
if (L.Util.isArray(latlngs[i]) && typeof latlngs[i][0] !== 'number') {
if (L.Util.isArray(latlngs[i]) && typeof latlngs[i][0] !== 'number') {
return;
}
target[i] = L.latLng(latlngs[i]);
Expand Down