Skip to content

Commit b3a1a9d

Browse files
author
Vladimir Elistratov
committed
updated coordArray
1 parent 8b1a567 commit b3a1a9d

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

coordArray.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,51 @@ return {
1010
push: function(feature, point) {
1111
var factory = this._getFactory(feature);
1212
if (!factory) return;
13+
14+
var _coords = feature.getCoords(),
15+
_point = feature.map.getCoords(point)
16+
;
17+
if (feature.getCoordsType() == "LineString") {
18+
_coords.push(_point);
19+
if (feature.coords != _coords) {
20+
feature.coords.push(point);
21+
}
22+
}
23+
1324
factory.push(feature, point);
1425
},
1526

1627
set: function(feature, index, point) {
1728
var factory = this._getFactory(feature);
1829
if (!factory) return;
30+
31+
var _coords = feature.getCoords(),
32+
_point = feature.map.getCoords(point)
33+
;
34+
if (feature.getCoordsType() == "LineString") {
35+
_coords[index] = _point;
36+
if (feature.coords != _coords) {
37+
feature.coords[index] = point;
38+
}
39+
}
40+
1941
factory.set(feature, index, point);
2042
},
43+
44+
remove: function(feature, index) {
45+
var factory = this._getFactory(feature);
46+
if (!factory) return;
47+
48+
var _coords = feature.getCoords();
49+
if (feature.getCoordsType() == "LineString") {
50+
_coords.splice(index, 1);
51+
if (feature.coords != _coords) {
52+
feature.coords.splice(index, 1);
53+
}
54+
}
55+
56+
factory.remove(feature, index);
57+
},
2158

2259
_getFactory: function(feature) {
2360
return feature.map.engine.getFactory(dependency);

djeo/CoordArray.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,14 @@ return declare(null, {
1010
},
1111

1212
push: function(feature, point) {
13-
var coords = feature.getCoords();
14-
point = feature.map.getCoords(point);
15-
if (feature.getCoordsType() == "LineString") {
16-
coords.push(point);
17-
}
1813
this._setShapes(feature);
1914
},
2015

2116
set: function(feature, index, point) {
22-
var coords = feature.getCoords();
23-
point = feature.map.getCoords(point);
24-
if (feature.getCoordsType() == "LineString") {
25-
coords[index] = point;
26-
}
17+
this._setShapes(feature);
18+
},
19+
20+
remove: function(feature, index) {
2721
this._setShapes(feature);
2822
},
2923

0 commit comments

Comments
 (0)