From 9072a11b259ed5a01c06e09f5c501722dc7e9772 Mon Sep 17 00:00:00 2001 From: Michel D'Astous Date: Wed, 9 Mar 2022 07:59:16 -0500 Subject: [PATCH] Improved validation of ESRI services before adding map layer (#3321) * Validate ESRI service supports 'Map' requests before making further tile requests. * changelog --- ...geo-validateEsriMapService_2022-03-08-20-15.json | 10 ++++++++++ core/frontend/src/tile/map/ArcGisUtilities.ts | 13 +++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 common/changes/@itwin/core-frontend/geo-validateEsriMapService_2022-03-08-20-15.json diff --git a/common/changes/@itwin/core-frontend/geo-validateEsriMapService_2022-03-08-20-15.json b/common/changes/@itwin/core-frontend/geo-validateEsriMapService_2022-03-08-20-15.json new file mode 100644 index 000000000000..a621c51fac97 --- /dev/null +++ b/common/changes/@itwin/core-frontend/geo-validateEsriMapService_2022-03-08-20-15.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@itwin/core-frontend", + "comment": "Improved validation of ESRI services before adding map layer", + "type": "none" + } + ], + "packageName": "@itwin/core-frontend" +} \ No newline at end of file diff --git a/core/frontend/src/tile/map/ArcGisUtilities.ts b/core/frontend/src/tile/map/ArcGisUtilities.ts index 2c2aab03a52b..26aa2698e93d 100644 --- a/core/frontend/src/tile/map/ArcGisUtilities.ts +++ b/core/frontend/src/tile/map/ArcGisUtilities.ts @@ -140,6 +140,19 @@ export class ArcGisUtilities { return { status: MapLayerSourceStatus.InvalidCredentials, authInfo: { authMethod: MapLayerAuthType.EsriToken } }; } + // Check this service support map queries + let hasMapCapability = false; + try { + if (json.capabilities + && typeof json.capabilities === "string" + && json.capabilities.toLowerCase().includes("map")) { + hasMapCapability = true; + } + } catch { } + if (!hasMapCapability) { + return { status: MapLayerSourceStatus.InvalidFormat}; + } + let subLayers; if (json.layers) {