Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.layer.props.data.length = 0;
}
this.update();
return;
}
if (!(CommonUtil.isArray(graphics))) {
graphics = [graphics];
}
for (let i = graphics.length - 1; i >= 0; i--) {
let graphic = graphics[i];
//如果我们传入的grapchic在graphics数组中没有的话,则不进行删除,
//并将其放入未删除的数组中。
let findex = CommonUtil.indexOf(this.graphics, graphic);
if (findex === -1) {
continue;
}
this.graphics.splice(findex, 1);
}
//删除完成后重新设置 setGraphics,以更新
this.update();
}
removeFeatures(features) {
if (!features || features.length === 0) {
return;
}
if (features === this.features) {
return this.removeAllFeatures();
}
if (!(CommonUtil.isArray(features))) {
features = [features];
}
var featuresFailRemoved = [];
for (var i = features.length - 1; i >= 0; i--) {
var feature = features[i];
//如果我们传入的feature在features数组中没有的话,则不进行删除,
//并将其放入未删除的数组中。
var findex = CommonUtil.indexOf(this.features, feature);
if (findex === -1) {
featuresFailRemoved.push(feature);
continue;
}
this.features.splice(findex, 1);
}
var drawFeatures = [];
for (var hex = 0, len = this.features.length; hex < len; hex++) {
feature = this.features[hex];
drawFeatures.push(feature);
}
this.features = [];
this.addFeatures(drawFeatures);
//绘制专题要素
if (this.renderer) {
this.redrawThematicFeatures(this.map.getBounds());
removeFeatures(features) {
if (!features || features.length === 0) {
return;
}
if (features === this.features) {
return this.removeAllFeatures();
}
if (!(CommonUtil.isArray(features))) {
features = [features];
}
var featuresFailRemoved = [];
for (var i = features.length - 1; i >= 0; i--) {
var feature = features[i];
//如果我们传入的feature在features数组中没有的话,则不进行删除,
//并将其放入未删除的数组中。
var findex = CommonUtil.indexOf(this.features, feature);
if (findex === -1) {
featuresFailRemoved.push(feature);
continue;
}
this.features.splice(findex, 1);
}
var drawFeatures = [];
for (var hex = 0, len = this.features.length; hex < len; hex++) {
feature = this.features[hex];
drawFeatures.push(feature);
}
this.features = [];
this.addFeatures(drawFeatures);
//绘制专题要素
if (this.renderer) {
this.redrawThematicFeatures(this.map.getView().calculateExtent());
removeFeatures(features) {
if (!features || features.length === 0 || !this.features || this.features.length === 0) {
return;
}
if (features === this.features) {
return this.removeAllFeatures();
}
if (!(CommonUtil.isArray(features))) {
features = [features];
}
var heatPoint, index, heatPointsFailedRemoved = [];
for (var i = 0, len = features.length; i < len; i++) {
heatPoint = features[i];
index = CommonUtil.indexOf(this.features, heatPoint);
//找不到视为删除失败
if (index === -1) {
heatPointsFailedRemoved.push(heatPoint);
continue;
}
//删除热点
this.features.splice(index, 1);
}
var succeed = heatPointsFailedRemoved.length == 0 ? true : false;
//派发删除features成功的事件
/**
* @event mapboxgl.supermap.HeatMapLayer#featuresremoved
* @description 要素删除之后触发。
* @property {Array.} features - 需要被删除的要素。
* @property {boolean} succeed - 要素删除成功与否。
*/
if (!graphics || graphics.length === 0 || graphics === this.graphics) {
this.graphics.length = 0;
this.update();
return;
}
if (!CommonUtil.isArray(graphics)) {
graphics = [graphics];
}
for (let i = graphics.length - 1; i >= 0; i--) {
let graphic = graphics[i];
//如果我们传入的grapchic在graphics数组中没有的话,则不进行删除,
//并将其放入未删除的数组中。
let findex = CommonUtil.indexOf(this.graphics, graphic);
if (findex === -1) {
continue;
}
this.graphics.splice(findex, 1);
}
//删除完成后重新设置 setGraphics,以更新
this.update();
}
removeFeatures: function (features) {
if (!features || features.length === 0 || !this.features || this.features.length === 0) {
return;
}
if (features === this.features) {
return this.removeAllFeatures();
}
if (!(CommonUtil.isArray(features))) {
features = [features];
}
var heatPoint, index, heatPointsFailedRemoved = [];
for (var i = 0, len = features.length; i < len; i++) {
heatPoint = features[i];
index = CommonUtil.indexOf(this.features, heatPoint);
//找不到视为删除失败
if (index === -1) {
heatPointsFailedRemoved.push(heatPoint);
continue;
}
//删除热点
this.features.splice(index, 1);
}
var succeed = heatPointsFailedRemoved.length == 0 ? true : false;
//派发删除features成功的事件
/**
* @event L.supermap.heatMapLayer#featuresremoved
* @description 删除features成功后触发。
* @property {Array.} features - 事件对象。
* @property {boolean} succeed - 删除是否成功,false 为失败,true 为成功。
*/