Utility Network Editor from ESRI UK Arcade Action to Zoom To Syntax

117
0
03-26-2024 08:07 AM
Billy
by
Occasional Contributor II

Hi, 

I'm not sure if this is the right place to post this question but I'm using the action scripting feature inside the Utility Network Editor (UNE) from ESRI UK (Utility Network Editor - Take Your Utility Network Everywhere | Esri UK).

The action scripting in UNE uses Arcade to trigger actions in the app. The syntax provided in the help documentation to "zoom to" a location is this: 

// Pan to a Location
return {
    command: "zoomto",
    geometry: Extent({
        xmin: 1000,
        ymin: 1000,
        xmax: 1000,
        ymax: 1000,
        spatialReference: { wkid: 102100 }
    })
};

 We are trying to use the code below. This code is trigger after using the Find functionality of the app and selecting one item in the search results. When we validate the code we get this for line 4: Execution Error:  Cannot read properties of null (reading 'spatialReference'). It looks like the Extent function is having a problem processing the geometry of the selected feature. When we comment-out line 4 and remove the "zoomto" command, the rest of the code works. The feature is selected, the map pans to the selected feature, the selected feature flashes; but no zoom to.  

 

 

 

var feature = $action.matchedFeature; // Get the selected feature
var featureGeometry = Geometry(feature); // Get the geometry of the selected feature

var extent = Extent(featureGeometry); // Calculate the extent of the selected feature's geometry

// If the feature geometry is null, return an empty extent
if (IsEmpty(featureGeometry)) {
  extent = Extent({xmin: 0, ymin: 0, xmax: 0, ymax: 0, spatialReference: {wkid: 102100}});
}

// Select Features
return [ 

// Select the search feature
{
  command: "select",
  method: "new",
  layers: [
    {
      layerid: $action.matchedlayerid,
      graphics: [$action.matchedfeature]
    }
  ]
}, 

// Pan to a Location
{
  command: "panto",
  geometry: featureGeometry,
  flash: true
},

// Zoom to a Location
{
  command: "zoomto",
  geometry: extent 
}

];

 

 

 

0 Kudos
0 Replies