Export (0) Print
Expand All

MapPolygon Class

Bing
Represents a polygon on the map.

Namespace: Microsoft.Maps.MapControl.WPF
Assembly: Microsoft.Maps.MapControl.WPF (in Microsoft.Maps.MapControl.WPF)

Visual Basic
Dim instance As MapPolygon

public class MapPolygon : MapShapeBase

The following example shows how to add a polygon to the map using XAML, C# and Visual Basic. For more information, see Adding Shapes to the Map.

<Window x:Class="WPFTestApplication.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
    Width="1024" Height="768">
    <Grid x:Name="LayoutRoot" Background="White">
        <m:Map CredentialsProvider="InsertYourBingMapsKey" Center="47.640,-122.125" ZoomLevel="11">
            <m:MapPolygon Fill="Blue" Stroke="Green" StrokeThickness="5" 
                          Locations="47.6424,-122.3219 47.8424,-122.1747 47.5814,-122.1747" 
                          Opacity="0.7"/>
        </m:Map>
    </Grid>
</Window>

void addNewPolygon()
{
    MapPolygon polygon = new MapPolygon();
    polygon.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue);
    polygon.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green);
    polygon.StrokeThickness = 5;
    polygon.Opacity = 0.7;
    polygon.Locations = new LocationCollection() { 
        new Location(47.6424,-122.3219), 
        new Location(47.8424,-122.1747), 
        new Location(47.5814,-122.1747};

    myMap.Children.Add(polygon);
}


System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
             System.Windows.Controls.Panel
               Microsoft.Maps.MapControl.WPF.MapShapeBase
                Microsoft.Maps.MapControl.WPF.MapPolygon

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

Target Platforms

Show:
© 2014 Microsoft