Canadian-Geospatial-Platform / geoview

Canadian Geospatial Platform Viewer / Visualiseur de la Plateforme Géospatiale Canadienne
Other
22 stars 31 forks source link

[BUG] ESRI Feature/Dynamic layer without geometryField in metadata fails to render #2212

Closed jaredkinger closed 3 weeks ago

jaredkinger commented 1 month ago

Is there an existing issue for this?

Current Behavior

An ESRI layer that does not include the geometryField in the metadata will fail to render with the following error:

TypeError: Cannot read properties of undefined (reading 'name')
    at esri-layer-common.ts:299:62
    at Array.forEach (<anonymous>)
    at L (esri-layer-common.ts:298:47)
    at t.value (esri-dynamic.ts:226:5)
    at esri-layer-common.ts:404:15
    at f (regeneratorRuntime.js:45:16)
    at Generator.<anonymous> (regeneratorRuntime.js:133:17)
    at Generator.next (regeneratorRuntime.js:74:21)
    at r (asyncToGenerator.js:3:20)
    at s (asyncToGenerator.js:22:9)

Expected Behavior

The ESRI layer should still be rendered even if the geometryField does not exist

Steps To Reproduce

  1. Go here: https://wordpress.dev.geo.ca/wp-content/geoview/examples/science2.html
  2. The layer should fail to load and generate an error in the notification panel
  3. View the console to see the TypeError

Anything else?

Example config: science2.json

Web Service URL: https://agriculture.canada.ca/atlas/rest/services/mapservices/aafc_national_ecological_framework_of_canada/MapServer/33

This only affects esriDynamic and esriFeature layers. Changing the layer to esriImage in the example will render the layer correctly but the legend and data table info will be missing.