Relation Online

This sample demonstrates use of a GeometryService to calculate topological relationships. To use the sample, click points on the map and click Execute. The relationship of the points to the pre-defined polygons on the map is calculated and added to the points' MapTips.

In the code-behind, a GeometryService is used to check whether the points are in the polygons by specifying a relation parameter of esriGeometryRelationWithin. The results are added to the points' MapTips when the are returned.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.Relation"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <esri:PictureMarkerSymbol x:Key="DefaultPointMarkerSymbol" OffsetX="0" OffsetY="23" Source="/Assets/Images/flag-red-24x24.png" />
            <esri:SimpleFillSymbol x:Key="DefaultPolygonFillSymbol" Fill="#660000FF" BorderBrush="Blue" BorderThickness="4" />
            <LinearGradientBrush x:Key="PanelGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                <LinearGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                        <SkewTransform CenterY="0.5" CenterX="0.5"/>
                        <RotateTransform Angle="176" CenterY="0.5" CenterX="0.5"/>
                        <TranslateTransform/>
                    </TransformGroup>
                </LinearGradientBrush.RelativeTransform>
                <GradientStop Color="#FF145787" Offset="0.16"/>
                <GradientStop Color="#FF3D7FAC" Offset="0.502"/>
                <GradientStop Color="#FF88C5EF" Offset="0.984"/>
            </LinearGradientBrush>
        </Grid.Resources>

        <esri:Map x:Name="MyMap" Extent="-118,32,-116,35">
            <esri:Map.Layers>

                <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
                      Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />

                <esri:GraphicsLayer ID="MyPolygonGraphicsLayer">
                    <esri:GraphicsLayer.Graphics >
                        <esri:Graphic x:Name="Graphic0" Symbol="{StaticResource DefaultPolygonFillSymbol}">
                            <esri:Polygon x:Name="Polygon_0">
                                <esri:Polygon.Rings>
                                    <esri:PointCollection>-117,33 -116.5,33 -116.5,34 -117,34 -117,33</esri:PointCollection>
                                </esri:Polygon.Rings>
                            </esri:Polygon>
                        </esri:Graphic>
                        <esri:Graphic x:Name="Graphic1" Symbol="{StaticResource DefaultPolygonFillSymbol}">
                            <esri:Polygon x:Name="Polygon_1">
                                <esri:Polygon.Rings>
                                    <esri:PointCollection>-118,34 -117.5,34 -117.5,35 -118,35 -118,34</esri:PointCollection>
                                </esri:Polygon.Rings>
                            </esri:Polygon>
                        </esri:Graphic>
                        <esri:Graphic x:Name="Graphic2" Symbol="{StaticResource DefaultPolygonFillSymbol}">
                            <esri:Polygon x:Name="Polygon_2">
                                <esri:Polygon.Rings>
                                    <esri:PointCollection>-116,32 -117,32 -117,33.5 -116,33.5 -116,32</esri:PointCollection>
                                </esri:Polygon.Rings>
                            </esri:Polygon>
                        </esri:Graphic>
                        <esri:Graphic x:Name="Graphic3" Symbol="{StaticResource DefaultPolygonFillSymbol}">
                            <esri:Polygon x:Name="Polygon_3">
                                <esri:Polygon.Rings>
                                    <esri:PointCollection>-115,31 -115.5,31 -115.5,32 -115,32 -115,31</esri:PointCollection>
                                </esri:Polygon.Rings>
                            </esri:Polygon>
                        </esri:Graphic>
                    </esri:GraphicsLayer.Graphics>
                    <esri:GraphicsLayer.MapTip>
                        <Grid Background="LightYellow">
                            <StackPanel Orientation="Vertical" Margin="5">
                                <TextBlock Text="{Binding [Name]}" HorizontalAlignment="Left" Foreground="Black" />
                                <TextBlock Text="{Binding [Relation]}" HorizontalAlignment="Left" Foreground="Black"/>
                            </StackPanel>
                            <Border BorderBrush="Black" BorderThickness="1" />
                        </Grid>
                    </esri:GraphicsLayer.MapTip>
                </esri:GraphicsLayer>

                <esri:GraphicsLayer ID="MyPointGraphicsLayer">
                    <esri:GraphicsLayer.MapTip>
                        <Grid Background="LightYellow">
                            <StackPanel Orientation="Vertical" Margin="5">
                                <TextBlock Text="{Binding [Name]}" HorizontalAlignment="Left" Foreground="Black"/>
                                <TextBlock Text="{Binding [Relation]}" HorizontalAlignment="Left" Foreground="Black" />
                            </StackPanel>
                            <Border BorderBrush="Black" BorderThickness="1" />
                        </Grid>
                    </esri:GraphicsLayer.MapTip>
                </esri:GraphicsLayer>

            </esri:Map.Layers>
        </esri:Map>

        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0" >
            <Rectangle Stroke="Gray"  RadiusX="10" RadiusY="10" Fill="{StaticResource PanelGradient}" Margin="0,0,0,5" >
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
            <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="30,20,30,30" >
                <TextBlock x:Name="InformationText" Width="200" Foreground="Black" Text="Add points by clicking on map.  Click Execute to compute the relation between the points and the polygons. The results will be displayed by hovering over the polygons or markers." TextAlignment="Left"  TextWrapping="Wrap" />
                <Button x:Name="ExecuteRelationButton" Content="Execute" Click="ExecuteRelationButton_Click" Width="100" Visibility="Visible" Margin="0,5,0,0"/>
            </StackPanel>
        </Grid>

    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014