How to get extents of sublayers of given MapImageLayer

276
3
03-27-2019 04:13 AM
DanielaPetrova
New Contributor

Hi, I have a MapImageLayer with a bunch of sublayers and want to perform spatial queries to get polygons that intersects among every two sublayers. How to get the extent of a sublayer to set a geometry of the query?

Tags (2)
Reply
0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Daniela,

   You have to use a Query and queryTask on the sublayer url. Use QueryTask.executeForExtent:

https://developers.arcgis.com/javascript/3/jsapi/querytask-amd.html#executeforextent

Reply
0 Kudos
DanielaPetrova
New Contributor

I'm using ArcGIS JS API 4.10

There is the function I'm using by:

function spatialQuerySublayer(sublayer, extent) {
    let spatialQuery = sublayer.createQuery()
    spatialQuery.geometry = extent
    spatialQuery.spatialRelationship = 'intersects'
   spatialQuery.outFields = ['OBJECTID']
   return layer.queryFeatures(spatialQuery)
}

It is a spatial request of a sublayer against another sublayer, but I don't know how to take the extent of the sublayer which I do request againts

Reply
0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Daniela,

  Use the subLayer.url property to do a QueryTask and then use the QueryTask.executeForExtent method.

Reply
0 Kudos