How to use the @supermap/iclient-common.FetchRequest.get 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 / openlayers / mapping / WebMap.js View on Github external
let that = this, 
        url = layerInfo.url.trim();
        if(layerInfo.layerType  === "TILE"){
           // 直接使用动态投影方式请求数据
           let projection = {
            epsgCode: that.baseProjection.split(":")[1]
        }
        url += `.json?prjCoordSys=${JSON.stringify(projection)}`;
        }else{
            url += (url.indexOf('?') > -1 ? '&SERVICE=WMS&REQUEST=GetCapabilities' : '?SERVICE=WMS&REQUEST=GetCapabilities');
        }
        let options = {
            withCredentials: this.withCredentials,
            withoutFormatSuffix: true
        };
        FetchRequest.get(url, null, options).then(function (response) {
            return layerInfo.layerType  === "TILE" ? response.json() : response.text();
        }).then(function (result) {
            if (layerInfo.layerType === "TILE") {
                layerInfo.extent = [result.bounds.left, result.bounds.bottom, result.bounds.right, result.bounds.top];
                layerInfo.projection = `EPSG:${result.prjCoordSys.epsgCode}`;

                callback(layerInfo);
            } else {
                layerInfo.projection = that.baseProjection;
                callback(layerInfo);
            }
        });
    }
github SuperMap / iClient-JavaScript / src / openlayers / mapping / WebMap.js View on Github external
getMapInfo(url) {
        let that = this,
            mapUrl = url;
        if (url.indexOf('.json') === -1) {
            //传递过来的url,没有包括.json,在这里加上。
            mapUrl = `${url}.json`
        }
        FetchRequest.get(mapUrl, null, {
            withCredentials: this.withCredentials
        }).then(function (response) {
            return response.json();
        }).then(function (mapInfo) {
            if (mapInfo.succeed === false) {
                that.errorCallback && that.errorCallback(mapInfo.error, 'getMapFaild', that.map);
                return;
            }
            that.baseProjection = mapInfo.projection;
            that.mapParams = {
                title: mapInfo.title,
                description: mapInfo.description
            }; //存储地图的名称以及描述等信息,返回给用户

            // 多坐标系支持
            if(proj4){
github SuperMap / iClient-JavaScript / src / leaflet / mapping / WebMap.js View on Github external
getFeatureFromFileAdded: function (layerInfo, success, failed, isGraphic) {
        var url = isGraphic ? layerInfo.url + '?currentPage=1&&pageSize=9999999' : layerInfo.url;
        Request.get(url).then(response => response.json()).then(data => {
            success && success(data);
        }).catch(err => failed && failed(err));
    },
    getCartoCSS2Obj: function (cartoCSS) {
github SuperMap / iClient-JavaScript / src / mapboxgl / mapping / WebMap.js View on Github external
_filterWMTSIsMatched(mapInfo, matchedCallback) {
		let isMatched = false,
			matchMaxZoom = 22,
			url = mapInfo.url;
		let options = {
			withCredentials: false,
			withoutFormatSuffix: true
		};

		FetchRequest.get(url, null, options)
			.then(response => {
				return response.text();
			})
			.then(capabilitiesText => {
				let converts = convert ? convert : window.convert;
				let tileMatrixSet = JSON.parse(converts.xml2json(capabilitiesText, { compact: true, spaces: 4 }))
					.Capabilities.Contents.TileMatrixSet;
				for (let i = 0; i < tileMatrixSet.length; i++) {
					if (
						tileMatrixSet[i]['ows:Identifier'] &&
						tileMatrixSet[i]['ows:Identifier']['_text'] === mapInfo.tileMatrixSet
					) {
						if (DEFAULT_WELLKNOWNSCALESET.includes(tileMatrixSet[i]['WellKnownScaleSet']['_text'])) {
							isMatched = true;
						} else if (
							tileMatrixSet[i]['WellKnownScaleSet'] &&
github SuperMap / iClient-JavaScript / src / leaflet / components / distributedanalysis / DistributedAnalysisModel.js View on Github external
let fieldInfos = datasetInfo.fieldInfos || datasetInfo.fieldInfo || null;
            if (fieldInfos) {
                for (let i in fieldInfos) {
                    fields.push(fieldInfos[i].name)
                }
                /**
                 * @event L.supermap.components.DistributedAnalysisModel#datasetinfoloaded
                 * @description 数据集查询完成之后触发。
                 * @property {Object} result - 数据集数据。
                 * @property {string} result.type - 数据集类型。
                 * @property {Array.} result.fields - 数据集字段。
                 */ 
                me.fire('datasetinfoloaded', { 'result': { 'type': type, 'fields': fields } })
            } else {
                let fieldsUrl = data.childUriList[0].replace('//fields', '/fields');
                FetchRequest.get(fieldsUrl).then(function (response) {
                    return response.json();
                }).then(function (data) {
                    let fieldNames = data.fieldNames;
                    let fields = [];
                    for (let i in fieldNames) {
                        fields.push(fieldNames[i])
                    }
                    me.fire('datasetinfoloaded', { 'result': { 'type': type, 'fields': fields } })
                })
            }
        })
    }
github SuperMap / iClient-JavaScript / src / openlayers / overlay / vectortile / MapboxStyles.js View on Github external
_resolve() {
        if (!this.source) {
            this.source = Object.keys(this._mbStyle.sources)[0];
        }
        if (this._mbStyle.sprite) {
            const spriteScale = window.devicePixelRatio >= 1.5 ? 0.5 : 1;
            const sizeFactor = spriteScale == 0.5 ? "@2x" : "";
            //兼容一下iServer 等iServer修改
            this._mbStyle.sprite = this._mbStyle.sprite.replace("@2x", "");
            const spriteUrl = this._toSpriteUrl(this._mbStyle.sprite, this.path, sizeFactor + ".json");
            FetchRequest.get(spriteUrl)
                .then(response => response.json())
                .then(spritesJson => {
                    this._spriteData = spritesJson;
                    this._spriteImageUrl = this._toSpriteUrl(this._mbStyle.sprite, this.path, sizeFactor + ".png");
                    this._spriteImage = null;
                    const img = new Image();
                    img.crossOrigin = "anonymous";
                    img.onload = () => {
                        this._spriteImage = img;
                        this._initStyleFunction();
                    };
                    img.src = this._spriteImageUrl;
                });
        } else {
            this._initStyleFunction();
        }
github SuperMap / iClient-JavaScript / src / leaflet / overlay / TileVectorLayer.js View on Github external
initLayersInfo: function () {
        var me = this;
        var layersUrl = me.url + "/layers.json";
        FetchRequest.get(layersUrl, null, {
            timeout: me.options.timeout
        }).then(function (response) {
            return response.json();
        }).then(function (json) {
            me.layersInfoInitialized = true;
            me.layersInfo = json;
            if (!me.layersInfo) {
                return;
            }
            var layersInfo = {};
            for (var i = 0, len = me.layersInfo.length; i < len; i++) {
                var layers = me.layersInfo[i].subLayers.layers;
                for (var j = 0, len1 = layers.length; j < len1; j++) {
                    layers[j].layerIndex = len1 - j;
                    layersInfo[layers[j].name] = layers[j];
                }
github SuperMap / iClient-JavaScript / src / openlayers / mapping / WebMap.js View on Github external
getDataflowInfo(layerInfo, success, faild) {
        let that = this;
        let url = layerInfo.url, token;
        let requestUrl = that.server + 'apps/viewer/getUrlResource.json?url=' + encodeURIComponent(url) + '.json';
        if(layerInfo.credential && layerInfo.credential.token) {
            token = layerInfo.credential.token;
            requestUrl+= `?token=${token}`;
        }
        FetchRequest.get(requestUrl, null, {
            withCredentials: this.withCredentials
        }).then(function (response) {
            return response.json()
        }).then(function (result) {
            if(result && result.featureMetaData) {
                layerInfo.featureType = result.featureMetaData.featureType.toUpperCase();
                layerInfo.dataSource={dataTypes:{}};
                if(result.featureMetaData.fieldInfos && result.featureMetaData.fieldInfos.length > 0) {
                    result.featureMetaData.fieldInfos.forEach(function (data) {
                        let name = data.name.trim();
                        if(data.type === 'TEXT') {
                            layerInfo.dataSource.dataTypes[name] = "STRING";
                        } else if(['DOUBLE','INT','FLOAT','LONG','SHORT'].includes(data.type)) {
                            layerInfo.dataSource.dataTypes[name] = "NUMBER";
                        } else {
                            layerInfo.dataSource.dataTypes[name] = "UNKNOWN";
github SuperMap / iClient-JavaScript / src / openlayers / mapping / WebMap.js View on Github external
getDatasources(url) {
        return FetchRequest.get(`${url}/data/datasources.json`).then(function (response) {
            return response.json()
        }).then(function (datasource) {
            let datasourceNames = datasource.datasourceNames;
            return datasourceNames[0];
        });

    }
    /**