@@ -190,16 +190,14 @@ function addCredentialToUrl(url, credential) {
190190 * @description 获取数据集表头信息
191191 * @param {string } datasetUrl 数据集地址
192192 * @param {Object } credential
193- * @param {boolean } withCredentials
193+ * @param {Object } options
194194 */
195- function getRestDataFields ( datasetUrl , credential , withCredentials ) {
195+ function getRestDataFields ( datasetUrl , credential , options ) {
196196 const url = addCredentialToUrl ( `${ datasetUrl } /fields.json?returnAll=true` , credential ) ;
197- return FetchRequest . get ( url , {
198- withCredentials
199- } )
197+ return FetchRequest . get ( url , null , options )
200198 . then ( ( res ) => res . json ( ) )
201199 . then ( ( result ) => {
202- return result . data . map ( ( item ) => {
200+ return result . map ( ( item ) => {
203201 const { caption, name, isSystemField, type, maxLength, isZeroLengthAllowed } = item ;
204202 return {
205203 name,
@@ -218,13 +216,11 @@ function getRestDataFields(datasetUrl, credential, withCredentials) {
218216 * @description 获取值域
219217 * @param {string } datasetUrl
220218 * @param {Object } credential
221- * @param {boolean } withCredentials
219+ * @param {Object } options
222220 */
223- function getRestDataDomains ( datasetUrl , credential , withCredentials ) {
221+ function getRestDataDomains ( datasetUrl , credential , options ) {
224222 const url = addCredentialToUrl ( `${ datasetUrl } /domain.json` , credential ) ;
225- return FetchRequest . get ( url , {
226- withCredentials
227- } ) . then ( ( result ) => {
223+ return FetchRequest . get ( url , null , options ) . then ( ( result ) => {
228224 return result . json ( ) ;
229225 } ) ;
230226}
@@ -246,10 +242,10 @@ function sortRestdataField(fieldInfos) {
246242 return systemFields . concat ( nonsystemFields ) ;
247243}
248244
249- async function requestRestDataFieldsInfo ( datasetUrl , credential , withCredentials ) {
245+ async function requestRestDataFieldsInfo ( datasetUrl , credential , options ) {
250246 const [ fields , domains ] = await Promise . all ( [
251- getRestDataFields ( datasetUrl , credential , withCredentials ) ,
252- getRestDataDomains ( datasetUrl , credential , withCredentials )
247+ getRestDataFields ( datasetUrl , credential , options ) ,
248+ getRestDataDomains ( datasetUrl , credential , options )
253249 ] ) ;
254250 domains . forEach ( ( domain ) => {
255251 const { fieldName, type, rangeInfos, codeInfos } = domain ;
@@ -274,8 +270,8 @@ async function requestRestDataFieldsInfo(datasetUrl, credential, withCredentials
274270 * @param credential
275271 * @param withCredentials
276272 */
277- async function getRestDataFieldInfo ( datasetUrl , credential , withCredentials ) {
278- const fieldsInfos = await requestRestDataFieldsInfo ( datasetUrl , credential , withCredentials ) ;
273+ async function getRestDataFieldInfo ( datasetUrl , credential , options ) {
274+ const fieldsInfos = await requestRestDataFieldsInfo ( datasetUrl , credential , options ) ;
279275 return {
280276 fieldNames : fieldsInfos . map ( ( el ) => el . name ) ,
281277 fieldTypes : fieldsInfos . map ( ( el ) => el . type )
@@ -392,12 +388,9 @@ async function getRestDataGeojsonByWebMap(data, options) {
392388 targetEpsgCode : '4326' ,
393389 queryParameter : { name : datasetName + '@' + dataSourceName }
394390 } ;
395- const SQLConfig = {
396- withCredentials : options . withCredentials
397- } ;
398391 const datasetUrl = `${ url . split ( 'featureResults' ) [ 0 ] } datasources/${ dataSourceName } /datasets/${ datasetName } ` ;
399- const { fieldNames, fieldTypes } = await getRestDataFieldInfo ( datasetUrl , credential , options . withCredentials ) ;
400- const attrDataInfo = await FetchRequest . post ( url , SQLParams , SQLConfig ) ;
392+ const { fieldNames, fieldTypes } = await getRestDataFieldInfo ( datasetUrl , credential , options ) ;
393+ const attrDataInfo = await FetchRequest . post ( url , JSON . stringify ( SQLParams ) , options ) ;
401394 const featuresRes = await attrDataInfo . json ( ) ;
402395
403396 return {
@@ -409,9 +402,10 @@ async function getRestDataGeojsonByWebMap(data, options) {
409402/**
410403 * 获取单条item
411404 * @param href
405+ * @param option
412406 */
413407function getStructDataItemJson ( href , option ) {
414- return FetchRequest . get ( href , option )
408+ return FetchRequest . get ( href , null , option )
415409 . then ( ( res ) => res . json ( ) )
416410 . then ( ( data ) => {
417411 if ( data . succeed === false ) {
@@ -430,7 +424,7 @@ function getStructDataItemJson(href, option) {
430424 * @param options
431425 */
432426async function getStructDataItem ( href , options ) {
433- const data = await getStructDataItemJson ( href ) ;
427+ const data = await getStructDataItemJson ( href , options ) ;
434428 const { features, links = [ ] } = data || { } ;
435429 const nextInfo = links . find ( ( l ) => l . rel === 'next' ) ;
436430 if ( nextInfo ) {
@@ -552,7 +546,11 @@ function transformGeometryCoordinates(features, fromProjection, toProjection = '
552546 */
553547async function getStructuredDataGeojsonByWebMap ( data , options ) {
554548 const allFeature = await getStructDataGeojson ( data . dataId , options ) ;
555- const resultRes = await FetchRequest . get ( `${ options . server } web/datas/${ data . dataId } /structureddata.json` ) ;
549+ const resultRes = await FetchRequest . get (
550+ `${ options . server } web/datas/${ data . dataId } /structureddata.json` ,
551+ null ,
552+ options
553+ ) ;
556554 const result = await resultRes . json ( ) ;
557555 const projection = `EPSG:${ result . epsgCode } ` ;
558556 if ( projection !== 'EPSG:4326' ) {
@@ -1528,7 +1526,7 @@ function replaceSprite2X(url) {
15281526 */
15291527function getPixelRatioSpriteUrl ( url ) {
15301528 if ( window . devicePixelRatio > 1 && ! url . includes ( '/sprite@2x' ) ) {
1531- return replaceSprite2X ( url ) ;
1529+ return replaceSprite2X ( url ) ;
15321530 }
15331531 return url ;
15341532}
@@ -1593,11 +1591,7 @@ async function addTextures({ layers, sprite, spriteJson, scene, options }) {
15931591 const texture = ( l . texture || { } ) . values ;
15941592 const iconInfo = spriteJson [ texture ] ;
15951593 if ( iconInfo ) {
1596- const image = await changeSpriteIconToImgData (
1597- sprite ,
1598- { ...iconInfo , id : texture } ,
1599- options
1600- ) ;
1594+ const image = await changeSpriteIconToImgData ( sprite , { ...iconInfo , id : texture } , options ) ;
16011595 const style = l . style || { } ;
16021596 const color = style . textureColor ,
16031597 rotate = style . textureRotate ;
@@ -1956,7 +1950,12 @@ function getL7Layer(l) {
19561950export async function addL7Layers ( { map, webMapInfo, l7Layers, spriteDatas, options } ) {
19571951 // 添加L7图层
19581952 const { layers, sources, sprite } = webMapInfo ;
1959- const formateL7Layers = await restoreL7Layers ( { layers : l7Layers , sources, map, options } ) ;
1953+ const formateL7Layers = await restoreL7Layers ( {
1954+ layers : l7Layers ,
1955+ sources,
1956+ map,
1957+ options : Object . assign ( { withoutFormatSuffix : true } , options )
1958+ } ) ;
19601959 // 批量处理L7纹理
19611960 const scene = await getScene ( map ) ;
19621961 if ( Object . keys ( spriteDatas ) . length > 0 ) {
0 commit comments