Label Points

This sample demonstrates using the ArcGIS Runtime SDK for WPF to perform a geometry operation to calculate the location of label points. To use the sample, click the Add New Polygon button, then click subsequent points on the map to draw a polygon. Double-click to complete the polygon. When a polygon is completed, a label point for the polygon will be calculated and shown on the map.

In the code-behind, a LocalGeometryService created and the url is passed into a GeometryService which is used to first simplify the polygon and then get a label point. When the label point is returned, it is added to the map.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.LocalLabelPoints"
    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">

        <Grid.Resources>
            <esri:SimpleFillSymbol x:Key="DefaultPolygonSymbol" Fill="#7F0000FF" BorderBrush="Blue" BorderThickness="2" />
            <esri:PictureMarkerSymbol x:Key="DefaultRasterSymbol" OffsetX="12" OffsetY="12" Source="/Assets/Images/x-24x24.png" />
            <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="-15000000,2000000,-7000000,8000000" Background="#FFE3E3E3" >
            <esri:ArcGISLocalTiledLayer ID="BaseMap" Path="..\\Data\\TPKs\\Topographic.tpk"/>
            <esri:GraphicsLayer ID="labelGraphicsLayer" x:Name="_labelGraphicsLayer">
                <esri:GraphicsLayer.MapTip>
                    <Grid Background="LightYellow">
                        <StackPanel Orientation="Vertical" Margin="5">
                            <TextBlock Text="{Binding [X]}" HorizontalAlignment="Left" Foreground="Black" />
                            <TextBlock Text="{Binding [Y]}" HorizontalAlignment="Left" Foreground="Black"/>
                        </StackPanel>
                        <Border BorderBrush="Black" BorderThickness="1" />
                    </Grid>
                </esri:GraphicsLayer.MapTip>
            </esri:GraphicsLayer>
        </esri:Map>

        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" >
            <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Gray"  RadiusX="10" RadiusY="10" 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" Margin="30,25,25,30" >
                <TextBlock x:Name="ResponseText" Text="Create a polygon by clicking on map. The calculated position of a Label Point will be displayed." 
                    Width="250" TextAlignment="Left" TextWrapping="Wrap" Foreground="Black" />
                <Button x:Name="ClearGraphicsButton" Content="Clear Polygons" 
                        Click="ClearGraphicsButton_Click" />
            </StackPanel>
        </Grid>

    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014