LayerDefinition with Geometry

4186
6
Jump to solution
11-11-2014 01:49 AM
SelçukTınaz
New Contributor III

Hi,

       I have a map that has ArcgisDynamicMapServiceLayer. I also have a geometry that i need to limit map extent and data with it. I am able to limit extent there is no problem. But i also need to limit geographic data with this geometry. I tried 'LayerDefinition', but it is useless for me. It only supports where clause string not the geometry. Do you have any solution for me?

Thanks in Advance.

0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor

Yes ArcGISDynamicMapServiceLayer doesn't support spatial filters. We might imagine to create a custom layer that would clip the image returned by the server but that seems convoluted.

Else the built in solution is to use FeatureLayers with a geometry filter, but, as noticed, this means you have to create separate layers by sublayer ID and this means the features are loaded at client which can impact the performances.

View solution in original post

6 Replies
JenniferNery
Esri Regular Contributor

Hi.

As you have observed there is no Geometry filter on ArcGISDynamicMapServiceLayer, unlike FeatureLayer which can be filtered by current map extent if you have Mode=OnDemand. I know it's not equivalent but perhaps you can set MaximumResolution so the layer is not visible beyond this resolution. You can zoom to the desired geometry and get Map.Resolution then when you create the layer set its MaximumResolution to that value.

        <esri:Map x:Name="MyMap"
                  WrapAround="True">
          <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
                                             Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
                                             />
            <esri:ArcGISDynamicMapServiceLayer ID="DynamicLayer"
                                               Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/RecentEarthquakesRendered/Map..."
                                               MaximumResolution="13014.99815945433">
                <esri:ArcGISDynamicMapServiceLayer.LayerDefinitions>
                    <esri:LayerDefinition Definition=""
                </esri:ArcGISDynamicMapServiceLayer.LayerDefinitions>
            </esri:ArcGISDynamicMapServiceLayer>
        </esri:Map>

Or maybe subscribe to ExtentChanged and make the layer Visible=False. LayerDefinition is meant to filter by attribute. ArcGIS REST API - Services and Data Types

SelçukTınaz
New Contributor III

Hi Jennifer,

     Thank you for your reply. But i try that solution but it is useless for me. In my case, for example; there are two city. One will not see the others' data. But data is in the same service. So, i need geometric limitation.

Thanks

0 Kudos
SuleymanARSLAN
New Contributor III

You can use query option on a layer.

You can easily define geometry as spatial filter.

ArcGIS REST API

0 Kudos
SelçukTınaz
New Contributor III

You miss something. I need to do that in all layer same time on Arcgisdynamicmapservicelayer without any query operation . It is like LayerDefinition but without where clause. it must be with geometry.

Thanks

0 Kudos
SuleymanARSLAN
New Contributor III

Actually I did not miss. You can not apply spatial filter to whole map service. You can only apply to individual layers. So you have to create separate layer for each.

If you don't want to do it that way, you have to use attribute query. For that you have to overlay all layers with boundary layer and add field to each layer for filtering data.

DominiqueBroux
Esri Frequent Contributor

Yes ArcGISDynamicMapServiceLayer doesn't support spatial filters. We might imagine to create a custom layer that would clip the image returned by the server but that seems convoluted.

Else the built in solution is to use FeatureLayers with a geometry filter, but, as noticed, this means you have to create separate layers by sublayer ID and this means the features are loaded at client which can impact the performances.