(config)
| 220 | } |
| 221 | |
| 222 | export function L7LayerUtil(config) { |
| 223 | const { featureFilter, expression, spec, L7Layer, L7, proj4 } = config; |
| 224 | |
| 225 | /** |
| 226 | * @param {string} url |
| 227 | * @param {string} [token] |
| 228 | * @returns {string} |
| 229 | */ |
| 230 | function addCredentialToUrl(url, credential) { |
| 231 | if (!credential) { |
| 232 | return url; |
| 233 | } |
| 234 | const tokenInfo = `${credential.key || credential.name}=${credential.value}`; |
| 235 | const newUrl = url.includes('?') ? `${url}&${tokenInfo}` : `${url}?${tokenInfo}`; |
| 236 | return newUrl; |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * @description 获取数据集表头信息 |
| 241 | * @param {string} datasetUrl 数据集地址 |
| 242 | * @param {Object} credential |
| 243 | * @param {Object} options |
| 244 | */ |
| 245 | function getRestDataFields(datasetUrl, credential, options) { |
| 246 | const url = addCredentialToUrl(`${datasetUrl}/fields.json?returnAll=true`, credential); |
| 247 | return FetchRequest.get(url, null, options) |
| 248 | .then((res) => res.json()) |
| 249 | .then((result) => { |
| 250 | return result.map((item) => { |
| 251 | const { caption, name, isSystemField, type, maxLength, isZeroLengthAllowed } = item; |
| 252 | return { |
| 253 | name, |
| 254 | type, |
| 255 | title: caption, |
| 256 | visible: true, |
| 257 | isSystemField, |
| 258 | maxLength, // MaxLength字节最大长度 |
| 259 | isZeroLengthAllowed // 是否允许零长度 |
| 260 | }; |
| 261 | }); |
| 262 | }); |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * @description 获取值域 |
| 267 | * @param {string} datasetUrl |
| 268 | * @param {Object} credential |
| 269 | * @param {Object} options |
| 270 | */ |
| 271 | function getRestDataDomains(datasetUrl, credential, options) { |
| 272 | const url = addCredentialToUrl(`${datasetUrl}/domain.json`, credential); |
| 273 | return FetchRequest.get(url, null, options).then((result) => { |
| 274 | return result.json(); |
| 275 | }); |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * restdata字段排序,系统字段放在最前面 |
no outgoing calls
no test coverage detected