MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / removeGraphics

Function removeGraphics

src/leaflet/overlay/GraphicLayer.js:192–218  ·  view source on GitHub ↗

* @function GraphicLayer.prototype.removeGraphics * @description 删除要素数组,默认删除所有要素。 * @param {Array. } [graphics=null] - 删除的 graphics 数组。

(graphics = null)

Source from the content-addressed store, hash-verified

190 * @param {Array.<Graphic>} [graphics=null] - 删除的 graphics 数组。
191 */
192 removeGraphics(graphics = null) {
193 //当 graphics 为 null 、为空数组,或 === this.graphics,则清除所有要素
194 if (!graphics || graphics.length === 0 || graphics === this.graphics) {
195 this.graphics.length = 0;
196 this.update();
197 return;
198 }
199 if (!CommonUtil.isArray(graphics)) {
200 graphics = [graphics];
201 }
202
203 for (let i = graphics.length - 1; i >= 0; i--) {
204 let graphic = graphics[i];
205
206 //如果我们传入的grapchic在graphics数组中没有的话,则不进行删除,
207 //并将其放入未删除的数组中。
208 let findex = CommonUtil.indexOf(this.graphics, graphic);
209
210 if (findex === -1) {
211 continue;
212 }
213 this.graphics.splice(findex, 1);
214 }
215
216 //删除完成后重新设置 setGraphics,以更新
217 this.update();
218 },
219
220 /**
221 * @function GraphicLayer.prototype.setStyle

Callers

nothing calls this directly

Calls 2

indexOfMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected