Export (0) Print
Expand All

Pushpin class

Bing

Represents a pushpin on the map. Inherits from Control.

Hh850857.note(en-us,MSDN.10).gifNote:
This pushpin has a default Bing Maps style. You can add any XAML control, such as a custom MapPolygon, to the map to represent a pushpin.

Constructors

Definition Description

Pushpin()

Initializes a new instance of the Pushpin class.

Properties

Name Type Description

Text

string

Gets or sets the text for a pushpin.

Example

Add a pushpin to the map using XAML.

<bm:Map>
    <bm:Map.Children>
        <bm:Pushpin>
            <bm:MapLayer.Position>
                <bm:Location Latitude="46.849947" Longitude="-121.32168" />
            </bm:MapLayer.Position>
        </bm:Pushpin>
    </bm:Map.Children>
</bm:Map>

Add a pushpin to the map using code-behind.

Pushpin pushpin = new Pushpin();
pushpin.Text = "1";
MapLayer.SetPosition(pushpin, new Location(46.849947,-121.32168));
Map.Children.Add(pushpin);

Specify how overlapping pushpins are layered on a map. In this example, the second pushpin "B" is displayed on top because it has the lowest Canvas.ZIndex value.

<Canvas>
    <bm:Map>
        <bm:Map.Children>
            <bm:Pushpin Text="A">
                <bm:MapLayer.Position>
                    <bm:Location Latitude="40" Longitude="-120" />
                </bm:MapLayer.Position>
            </bm:Pushpin>
            <bm:Pushpin Text="B" Canvas.ZIndex="1">
                <bm:MapLayer.Position>
                    <bm:Location Latitude="40.05" Longitude="-120.05" />
                </bm:MapLayer.Position>
            </bm:Pushpin>
            <bm:Pushpin Text="C">
                <bm:MapLayer.Position>
                    <bm:Location Latitude="40.1" Longitude="-120.1" />
                </bm:MapLayer.Position>
            </bm:Pushpin>
        </bm:Map.Children>
    </bm:Map>
</Canvas>

Use the Tapped event to change a pushpin title. In this example, a message displays when you tap the pushpin.

<bm:Map ZoomLevel="7.5">
    <bm:Map.Center>
        <bm:Location Latitude="48" Longitude="-122.580489" />
    </bm:Map.Center>

    <bm:Map.Children>
        <bm:Pushpin Tapped="pushpinTapped">
            <bm:MapLayer.Position>
                <bm:Location Latitude="47.610039" Longitude="-122.342207" />
            </bm:MapLayer.Position>
        </bm:Pushpin>
    </bm:Map.Children>
</bm:Map>

private async void pushpinTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
    MessageDialog dialog = new MessageDialog("Hello from Seattle.");
    await dialog.ShowAsync();
}

Add Tapped event handler in code-behind

Pushpin p = new Pushpin();
p.Tapped += new TappedEventHandler(myTap);
          
private void myTap(object sender, TappedRoutedEventArgs e){ }

Show:
© 2014 Microsoft