How to use the @supermap/iclient-common.CommonUtil.indexOf function in @supermap/iclient-common

To help you get started, we’ve selected a few @supermap/iclient-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SuperMap / iClient-JavaScript / src / mapboxgl / overlay / GraphicLayer.js View on Github external
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();
    }
github SuperMap / iClient-JavaScript / src / mapboxgl / overlay / theme / ThemeLayer.js View on Github external
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());
github SuperMap / iClient-JavaScript / src / openlayers / overlay / theme / Theme.js View on Github external
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());
github SuperMap / iClient-JavaScript / src / mapboxgl / overlay / HeatMapLayer.js View on Github external
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 - 要素删除成功与否。
         */
github SuperMap / iClient-JavaScript / src / openlayers / overlay / Graphic.js View on Github external
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();
  }
github SuperMap / iClient-JavaScript / src / leaflet / overlay / HeatMapLayer.js View on Github external
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 为成功。
         */