Skip to content

Commit e9c9774

Browse files
committed
优化高性能图层大数据量下内存问题
1 parent f4b130d commit e9c9774

9 files changed

Lines changed: 33 additions & 27 deletions

File tree

‎dist/iclient9-leaflet.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65476,8 +65476,9 @@ var GraphicLayer = exports.GraphicLayer = _leaflet2["default"].Path.extend({
6547665476
* @param {Array<L.supermap.graphic>} graphics - 点要素对象数组
6547765477
*/
6547865478
setGraphics: function setGraphics(graphics) {
65479-
this.graphics = [];
65480-
var sGraphics = !_leaflet2["default"].Util.isArray(graphics) ? [graphics] : graphics.concat([]);
65479+
this.graphics = this.graphics || [];
65480+
this.graphics.length = 0;
65481+
var sGraphics = !_leaflet2["default"].Util.isArray(graphics) ? [graphics] : [].concat(graphics);
6548165482
this.graphics = [].concat(sGraphics);
6548265483
this._update();
6548365484
},
@@ -65490,7 +65491,7 @@ var GraphicLayer = exports.GraphicLayer = _leaflet2["default"].Path.extend({
6549065491
*/
6549165492
addGraphics: function addGraphics(graphics) {
6549265493
this.graphics = this.graphics || [];
65493-
var sGraphics = !_leaflet2["default"].Util.isArray(graphics) ? [graphics] : graphics.concat([]);
65494+
var sGraphics = !_leaflet2["default"].Util.isArray(graphics) ? [graphics] : [].concat(graphics);
6549465495
this.graphics = this.graphics.concat(sGraphics);
6549565496
this._update();
6549665497
},
@@ -65501,7 +65502,7 @@ var GraphicLayer = exports.GraphicLayer = _leaflet2["default"].Path.extend({
6550165502
* @description 移除所有要素
6550265503
*/
6550365504
removeGraphics: function removeGraphics() {
65504-
this.graphics = [];
65505+
this.graphics.length = 0;
6550565506
this._update();
6550665507
},
6550765508

‎dist/iclient9-leaflet.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/iclient9-mapboxgl.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58794,8 +58794,9 @@ var GraphicLayer = exports.GraphicLayer = function () {
5879458794
}, {
5879558795
key: 'setGraphics',
5879658796
value: function setGraphics(graphics) {
58797-
this.graphics = [];
58798-
var sGraphics = !_Util.Util.isArray(graphics) ? [graphics] : graphics.concat([]);
58797+
this.graphics = this.graphics || [];
58798+
this.graphics.length = 0;
58799+
var sGraphics = !_Util.Util.isArray(graphics) ? [graphics] : [].concat(graphics);
5879958800
//this.layer.props.data不能被重新赋值,只能在原数组上进行操作
5880058801
if (!this.layer.props.data) {
5880158802
this.layer.props.data = [];
@@ -58817,7 +58818,7 @@ var GraphicLayer = exports.GraphicLayer = function () {
5881758818
key: 'addGraphics',
5881858819
value: function addGraphics(graphics) {
5881958820
this.graphics = this.graphics || [];
58820-
var sGraphics = !_Util.Util.isArray(graphics) ? [graphics] : graphics.concat([]);
58821+
var sGraphics = !_Util.Util.isArray(graphics) ? [graphics] : [].concat(graphics);
5882158822
//this.layer.props.data不能被重新赋值,只能在原数组上进行操作
5882258823
if (!this.layer.props.data) {
5882358824
this.layer.props.data = [];
@@ -58854,7 +58855,7 @@ var GraphicLayer = exports.GraphicLayer = function () {
5885458855
}, {
5885558856
key: 'removeGraphics',
5885658857
value: function removeGraphics() {
58857-
this.graphics = [];
58858+
this.graphics.length = 0;
5885858859

5885958860
if (this.layer.props.data) {
5886058861
this.layer.props.data.length = 0;

‎dist/iclient9-mapboxgl.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/iclient9-openlayers.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63028,8 +63028,9 @@ var Graphic = exports.Graphic = function (_ol$source$ImageCanva) {
6302863028
_createClass(Graphic, [{
6302963029
key: 'setGraphics',
6303063030
value: function setGraphics(graphics) {
63031-
this.graphics_ = [];
63032-
var sGraphics = !_Util.Util.isArray(graphics) ? [graphics] : graphics.concat([]);
63031+
this.graphics_ = this.graphics_ || [];
63032+
this.graphics_.length = 0;
63033+
var sGraphics = !_Util.Util.isArray(graphics) ? [graphics] : [].concat(graphics);
6303363034
this.graphics_ = [].concat(sGraphics);
6303463035
this.update();
6303563036
}
@@ -63044,7 +63045,7 @@ var Graphic = exports.Graphic = function (_ol$source$ImageCanva) {
6304463045
key: 'addGraphics',
6304563046
value: function addGraphics(graphics) {
6304663047
this.graphics_ = this.graphics_ || [];
63047-
var sGraphics = !_Util.Util.isArray(graphics) ? [graphics] : graphics.concat([]);
63048+
var sGraphics = !_Util.Util.isArray(graphics) ? [graphics] : [].concat(graphics);
6304863049
this.graphics_ = this.graphics_.concat(sGraphics);
6304963050
this.update();
6305063051
}
@@ -63068,7 +63069,7 @@ var Graphic = exports.Graphic = function (_ol$source$ImageCanva) {
6306863069
}, {
6306963070
key: 'removeGraphics',
6307063071
value: function removeGraphics() {
63071-
this.graphics_ = [];
63072+
this.graphics_.length = 0;
6307263073
this.update();
6307363074
}
6307463075

‎dist/iclient9-openlayers.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/leaflet/overlay/GraphicLayer.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ export var GraphicLayer = L.Path.extend({
5252
* @param {Array<L.supermap.graphic>} graphics - 点要素对象数组
5353
*/
5454
setGraphics(graphics) {
55-
this.graphics = [];
56-
let sGraphics = !L.Util.isArray(graphics) ? [graphics] : graphics.concat([]);
55+
this.graphics = this.graphics || [];
56+
this.graphics.length = 0;
57+
let sGraphics = !L.Util.isArray(graphics) ? [graphics] : [].concat(graphics);
5758
this.graphics = [].concat(sGraphics);
5859
this._update();
5960
},
@@ -65,7 +66,7 @@ export var GraphicLayer = L.Path.extend({
6566
*/
6667
addGraphics(graphics) {
6768
this.graphics = this.graphics || [];
68-
let sGraphics = !L.Util.isArray(graphics) ? [graphics] : graphics.concat([]);
69+
let sGraphics = !L.Util.isArray(graphics) ? [graphics] : [].concat(graphics);
6970
this.graphics = this.graphics.concat(sGraphics);
7071
this._update();
7172
},
@@ -75,7 +76,7 @@ export var GraphicLayer = L.Path.extend({
7576
* @description 移除所有要素
7677
*/
7778
removeGraphics() {
78-
this.graphics = [];
79+
this.graphics.length = 0;
7980
this._update();
8081
},
8182

‎src/mapboxgl/overlay/GraphicLayer.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ export class GraphicLayer {
174174
* @param {Array<mapboxgl.supermap.Graphic>} graphics - 点要素对象数组
175175
*/
176176
setGraphics(graphics) {
177-
this.graphics = [];
178-
let sGraphics = !Util.isArray(graphics) ? [graphics] : graphics.concat([]);
177+
this.graphics = this.graphics || [];
178+
this.graphics.length = 0;
179+
let sGraphics = !Util.isArray(graphics) ? [graphics] : [].concat(graphics);
179180
//this.layer.props.data不能被重新赋值,只能在原数组上进行操作
180181
if (!this.layer.props.data) {
181182
this.layer.props.data = [];
@@ -194,7 +195,7 @@ export class GraphicLayer {
194195
*/
195196
addGraphics(graphics) {
196197
this.graphics = this.graphics || [];
197-
let sGraphics = !Util.isArray(graphics) ? [graphics] : graphics.concat([]);
198+
let sGraphics = !Util.isArray(graphics) ? [graphics] : [].concat(graphics);
198199
//this.layer.props.data不能被重新赋值,只能在原数组上进行操作
199200
if (!this.layer.props.data) {
200201
this.layer.props.data = [];
@@ -225,7 +226,7 @@ export class GraphicLayer {
225226
* @description 移除所有要素
226227
*/
227228
removeGraphics() {
228-
this.graphics = [];
229+
this.graphics.length = 0;
229230

230231
if (this.layer.props.data) {
231232
this.layer.props.data.length = 0;

‎src/openlayers/overlay/Graphic.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ export class Graphic extends ol.source.ImageCanvas {
175175
* @param {Array<ol.Graphic>} graphics - 点要素对象数组
176176
*/
177177
setGraphics(graphics) {
178-
this.graphics_ = [];
179-
let sGraphics = !Util.isArray(graphics) ? [graphics] : graphics.concat([]);
178+
this.graphics_ = this.graphics_ || [];
179+
this.graphics_.length = 0;
180+
let sGraphics = !Util.isArray(graphics) ? [graphics] : [].concat(graphics);
180181
this.graphics_ = [].concat(sGraphics);
181182
this.update();
182183
}
@@ -188,7 +189,7 @@ export class Graphic extends ol.source.ImageCanvas {
188189
*/
189190
addGraphics(graphics) {
190191
this.graphics_ = this.graphics_ || [];
191-
let sGraphics = !Util.isArray(graphics) ? [graphics] : graphics.concat([]);
192+
let sGraphics = !Util.isArray(graphics) ? [graphics] : [].concat(graphics);
192193
this.graphics_ = this.graphics_.concat(sGraphics);
193194
this.update();
194195
}
@@ -206,7 +207,7 @@ export class Graphic extends ol.source.ImageCanvas {
206207
* @description 清除所有要素
207208
*/
208209
removeGraphics() {
209-
this.graphics_ = [];
210+
this.graphics_.length = 0;
210211
this.update();
211212
}
212213

0 commit comments

Comments
 (0)