Select to view content in your preferred language

Feature Layer zIndex

2149
2
05-31-2020 04:29 PM
AndrewMurdoch1
Frequent Contributor

Good Day

I'm trying to figure out how change the elevation / zIndex of layer at creation, assuming I have N layers, and I want 'Base' to be on the bottom, how do I go about that?  This is my layer creation code:

let offset = '';
  if (!data[0].attributes.geoLayerName.toUpperCase().includes('BASE')) {
    offset = 'Geometry($feature).z + 10000';
  } else {
    offset = 'Geometry($feature).z + 10';
  }

return {
  source: data,
  renderer: this.buildRenderSettings(colour, geometryType === 'point'),
  fields: this._fields,
  objectIdField: 'ObjectID',
  geometryType: geometryType,
  elevationInfo: {
    mode: 'absolute-height',
    featureExpressionInfo: {
      expression: offset
    },
    unit: 'meters'
  },
  spatialReference: {
    wkid: 4326
  }
};

I'm utilizing a 2D map.

Thanks

Tags (1)
0 Kudos
2 Replies
JohnGrayson
Esri Regular Contributor

From the Help doc:(FeatureLayer | ArcGIS API for JavaScript 4.15"This property may only be used in a SceneView".  Try controlling the layer order based on the order in the Map.layers collection.  If you need to reorder the layers after they've been added you can use the 'reorder()' method of the Map (Map | ArcGIS API for JavaScript 4.15)

AndrewMurdoch1
Frequent Contributor

Thanks for the reply, it seems they made a large oversight.  I ended up reordering the map data before I convert it to Feature Layers which solves the problem.

0 Kudos