I need to be able to restrict what features on a layer a user can see based on their geographical location.
Here's the scenario: this is for contractor management for my company. A contractor needs to be restricted to a geographical area, most often a state (but sometimes it will be a polygon drawn from another layer) and only see features from the map's feature layers within that geographical area. So if they're restricted to Ohio, they need to not be able to see features in Indiana, Kentucky, etc.
Is there any way to set a layer to only display features within a certain geometry?
Solved! Go to Solution.
Hi @jbarrmetro, for this, you should be able to use a query with the FeatureLayer against the geometry of interest.
If it's a hosted FeatureLayer, you can use the queryExtent() method on the FeatureLayer:
If it's not, you can use the executeQueryJSON() method:
https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-query.html#executeQueryJSON
Hi @jbarrmetro, for this, you should be able to use a query with the FeatureLayer against the geometry of interest.
If it's a hosted FeatureLayer, you can use the queryExtent() method on the FeatureLayer:
If it's not, you can use the executeQueryJSON() method:
https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-query.html#executeQueryJSON
@Noah-Sager let me see if I'm understanding a possible path forward here based on your reply:
Does that make sense? Sound feasible?
Bingo, that makes sense to me and sounds feasible.
@Noah-Sager ok, thanks! Any suggestions on what to do if I run out of room on the 2000 feature limit for a query (as seems entirely possible when querying a whole state)? How do I re-query in a way that doesn't just get duplicate results from the first query?