How to use the @supermap/iclient-common.CommonUtil.isArray 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 / theme / ThemeLayer.js View on Github external
toiClientFeature(features) {
        if (!CommonUtil.isArray(features)) {
            features = [features];
        }

        let featuresTemp = [];
        for (let i = 0; i < features.length; i++) {
            //mapboxgl.supermap.ThemeFeature 类型
            if (features[i] instanceof ThemeFeature) {
                featuresTemp.push(features[i].toFeature());
            } else if (features[i] instanceof GeometryVector) {
                // 若是 GeometryVector 直接返回
                featuresTemp.push(features[i]);
            } else if (["FeatureCollection", "Feature", "Geometry"].indexOf(features[i].type) != -1) {
                //GeoJSON 规范数据类型
                let format = new GeoJSONFormat();
                featuresTemp = featuresTemp.concat(format.read(features[i]));
            } else if (features[i].geometry && features[i].geometry.parts) {
github SuperMap / iClient-JavaScript / src / leaflet / overlay / theme / ThemeLayer.js View on Github external
toiClientFeature: function (features) {
        //若 features 非数组形式 feature 则先做以下处理:
        if (!CommonUtil.isArray(features)) {
            features = [features];
        }

        let featuresTemp = [];
        for (let i = 0; i < features.length; i++) {
            //L.supermap.themeFeature 数据类型
            if (features[i] instanceof ThemeFeature) {
                featuresTemp.push(features[i].toFeature());
            } else if (features[i] instanceof GeometryVector) {
                // 若是 GeometryVector 类型直接返回
                featuresTemp.push(features[i]);
            } else if (["FeatureCollection", "Feature", "Geometry"].indexOf(features[i].type) != -1) {
                //GeoJSON 规范数据类型
                const format = new GeoJSONFormat();
                featuresTemp = featuresTemp.concat(format.read(features[i]));
            } else if (features[i].geometry && features[i].geometry.parts) {
github SuperMap / iClient-JavaScript / src / leaflet / overlay / carto / CartoCSSToLeaflet.js View on Github external
return [];
            case 'dot':
                return [1, 4 * w];
            case 'dash':
                return [4 * w, 4 * w];
            case 'dashdot':
                return [4 * w, 4 * w, 1, 4 * w];
            case 'longdash':
                return [8 * w, 4 * w];
            case 'longdashdot':
                return [8 * w, 4 * w, 1, 4 * w];
            default:
                if (!str) {
                    return [];
                }
                if (Util.isArray(str)) {
                    return str;
                }
                str = StringExt.trim(str).replace(/\s+/g, ",");
                return str.replace(/\[|\]/gi, "").split(",");
        }
    }
github SuperMap / iClient-JavaScript / src / openlayers / core / StyleUtils.js View on Github external
return [0];
      case 'dot':
        return [1, 4 * w];
      case 'dash':
        return [4 * w, 4 * w];
      case 'dashdot':
        return [4 * w, 4 * w, 1, 4 * w];
      case 'longdash':
        return [8 * w, 4 * w];
      case 'longdashdot':
        return [8 * w, 4 * w, 1, 4 * w];
      default:
        if (!str) {
          return [];
        }
        if (CommonUtil.isArray(str)) {
          return str;
        }
        str = StringExt.trim(str).replace(/\s+/g, ",");
        return str.replace(/\[|\]/gi, "").split(",");
    }
  }
github SuperMap / iClient-JavaScript / src / mapboxgl / mapping / WebMap.js View on Github external
return [];
			case 'dot':
				return [1, 4 * w];
			case 'dash':
				return [4 * w, 4 * w];
			case 'dashdot':
				return [4 * w, 4 * w, 1 * w, 4 * w];
			case 'longdash':
				return [8 * w, 4 * w];
			case 'longdashdot':
				return [8 * w, 4 * w, 1, 4 * w];
			default:
				if (!str) {
					return [];
				}
				if (CommonUtil.isArray(str)) {
					return str;
				}
				str = StringExt.trim(str).replace(/\s+/g, ',');
				return str.replace(/\[|\]/gi, '').split(',');
		}
	}
github SuperMap / iClient-JavaScript / src / leaflet / core / Transform.js View on Github external
function _prepareFeatuers(feature) {
        const geometry = feature.geometry;
        if (!(CommonUtil.isArray(geometry.coordinates))) {
            throw "Geometry must have coordinates array: " + geometry;
        }
        if (!parseCoords[geometry.type.toLowerCase()]) {
            throw "Unsupported geometry type: " + geometry.type;
        }
        try {
            geometry.coordinates = parseCoords[geometry.type.toLowerCase()].apply(
                this, [geometry.coordinates]
            );
        } catch (err) {
            throw err;
        }
        feature.geometry = geometry;
        return feature;
    }
github SuperMap / iClient-JavaScript / src / mapboxgl / overlay / GraphicLayer.js View on Github external
removeGraphics(graphics = null) {
        //当 graphics 为 null 、为空数组,或 === this.graphics,则清除所有要素
        if (!graphics || graphics.length === 0 || graphics === this.graphics) {
            this.graphics.length = 0;

            if (this.layer.props.data) {
                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);
        }
github SuperMap / iClient-JavaScript / src / openlayers / overlay / theme / Theme.js View on Github external
toiClientFeature(features) {
        if (!CommonUtil.isArray(features)) {
            features = [features];
        }

        let featuresTemp = [];
        for (let i = 0; i < features.length; i++) {

            if (features[i] instanceof ThemeFeature) {
                //ol.supermap.ThemeFeature 类型
                featuresTemp.push(features[i].toFeature());
                continue;
            } else if (features[i] instanceof ol.Feature) {
                //ol.Feature 数据类型
                //_toFeature 统一处理 ol.Feature 所有 geometry 类型
                featuresTemp.push(this._toFeature(features[i]));
                continue;
            } else if (features[i] instanceof GeometryVector) {
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++) {