Select to view content in your preferred language

Using the ArcGIS JS SDK, all calls I make to an Image Server Identify yield "Right side of assignment cannot be destructured" error

305
1
09-17-2024 09:11 AM
check-your-crs
New Contributor

I am trying to query an ArcGIS ImageServer (specifically Sentinel2) using the `ImageryLayer.identify()` function. Every combination of parameters I've used leads to "TypeError: Right side of assignment cannot be destructured". I found a StackOverflow thread about that error message.

Example code 1

 

const url = 'https://ic.imagery1.arcgis.com/arcgis/rest/services/Sentinel2_10m_LandCover/ImageServer';
const imageryLayer = new ImageryLayer({
   url,
});
const identity = await imageryLayer.identify({
// Every combination of parameters, including none at all, leads to the same error.
   geometry: geometry: new Point({
      x: 0,
      y: 0,
      spatialReference: new SpatialReference({ wkid: 3857 }),
   }),
   returnCatalogItems: false,
   returnGeometry: false,
   returnPixelValues: true,
});

 

This only happens when I create the `imageryLayer` from a URL, but not from an item ID. Doing that leads to a different error, but still independent of the parameters I use.

Example code 2

 

const imageryLayer = new ImageryLayer({
   id: 'ITEM_ID_HERE',
});
// Keep everything else the same.
// This leads to the following error: `JSON Parse error: Unrecognized token '<'.`

 

This leads to the following error: "JSON Parse error: Unrecognized token '<'.

I also created a question on StackOverflow for this.

0 Kudos
1 Reply
Sage_Wall
Esri Regular Contributor

Hi @check-your-crs ,

I think you likely just need to wait for the imageryLayer to load before you do the identify.

 

const url = 'https://ic.imagery1.arcgis.com/arcgis/rest/services/Sentinel2_10m_LandCover/ImageServer';
const imageryLayer = new ImageryLayer({
   url,
});

await imageryLayer.load();

const identity = await imageryLayer.identify({
   geometry: geometry: new Point({
      x: 0,
      y: 0,
      spatialReference: new SpatialReference({ wkid: 3857 }),
   }),
   returnCatalogItems: false,
   returnGeometry: false,
   returnPixelValues: true,
});

 

 https://codepen.io/sagewall/pen/poXMjwa?editors=1010 

0 Kudos