How to implement masking for areas outside a polygons

551
3
03-28-2019 12:14 AM
Bhaskar_ReddyPulsani
New Contributor

I have a administrative polygon boundaries such as District, Mandal and Villages. When i zoom to district,  I want to mask the area that is outside of polygon boundary. Right now i am using arcgis javascript api 3.27 for arcgis 10.2 server.

The mask functionality exists on arcgis for desktop where on can clip to shape. I want a similar functionality for arcgis javascript api. does anyone have any idea about it. earlier it existed for flex api but unfortunately i couldn't find it for javascript api

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Bhaskar,

  In the JS API 4.11 this is possible using the new FeatureEffects class. 4.11 will be available soon (this week). In 3.x one way I can think to do this is to add a DefeenitionExpression to the boundary layer that only allows the selected boundary to show. https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#setdefinitionexpression

0 Kudos
Bhaskar_ReddyPulsani
New Contributor

Robert, 

thank you very much for the reply. I have gone through the feature effects class and here is a sample that implements it:

https://developers.arcgis.com/javascript/latest/sample-code/featureeffect-geometry/index.html

The feature effects class is querying features to a buffered area or any desired area and its not clipping to that area. here's a snapshot of the class results:

What i am looking for is to have any number of features showing in this buffer zone or any area and then setting the outside boundary of this area to white like shown below:

As for the definition query, I have about 20 to 30 layers making a whole map and to implement so many queries is going to be difficult and also for line layers line national and state highways, the lines don't have any village or mandal or district specifications in their attributes.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Sorry I don't think I can help with that.

0 Kudos