Back to Devexpress

MapPushpin Class

wpf-devexpress-dot-xpf-dot-map-7a9fcd33.md

latest6.4 KB
Original Source

MapPushpin Class

The class used to draw a pushpin on a map.

Namespace : DevExpress.Xpf.Map

Assembly : DevExpress.Xpf.Map.v25.2.dll

NuGet Package : DevExpress.Wpf.Map

Declaration

csharp
public class MapPushpin :
    MapItem,
    IWeakEventListener,
    ISupportCoordLocation,
    IPointCore,
    IClusterable,
    IClusterItemCore,
    IClusterItem
vb
Public Class MapPushpin
    Inherits MapItem
    Implements IWeakEventListener,
               ISupportCoordLocation,
               IPointCore,
               IClusterable,
               IClusterItemCore,
               IClusterItem

The following members return MapPushpin objects:

Remarks

A pushpin is a pointer that marks a geographical point on a map.

A typical map pushpin is shown in the image below.

An instance of a map pushpin is represented by the MapPushpin object that is descendant of a VectorLayer object.

Use the MapPushpin.Location property to specify the pushpin position on a map.

In addition, you can change the pushpin state (MapPushpin.State), specify its text (MapPushpin.Text) and other appearance settings (MapPushpin.TraceDepth, MapPushpin.TraceStroke).

To learn more on pushpins, see the Vector Items topic.

Example

This example illustrates how to provide animation for a map pushpin.

To do this, it is necessary to create a PushpinLocationAnimation object and assign it to the MapPushpin.LocationChangedAnimation property. After that, it becomes possible to customize the animation duration (PushpinLocationAnimation.Duration) and easing function (PushpinLocationAnimation.EasingFunction).

In addition, you can change the pushpin state after its location animation is complete via the PushpinLocationAnimation.Completed event. In this example, this event is used to change the pushpin location randomly each time the bouncing animation effect is complete.

xaml
<Window x:Class="LocationAnimation.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"
        Title="MainWindow" Height="350" Width="525" >    
    <Grid>
        <dxm:MapControl>
            <dxm:ImageTilesLayer>
                <dxm:ImageTilesLayer.DataProvider>
                    <dxm:OpenStreetMapDataProvider/>
                </dxm:ImageTilesLayer.DataProvider>
            </dxm:ImageTilesLayer>
            <dxm:VectorLayer>
                <dxm:MapItemStorage>
                    <dxm:MapPushpin x:Name="pushpin" TraceDepth="30" TraceStroke="Red" >
                        <dxm:MapPushpin.LocationChangedAnimation>
                            <dxm:PushpinLocationAnimation Duration="00:00:02" Completed="PushpinLocationAnimation_Completed" >
                                <dxm:PushpinLocationAnimation.EasingFunction>
                                    <BounceEase/>
                                </dxm:PushpinLocationAnimation.EasingFunction>
                            </dxm:PushpinLocationAnimation>
                        </dxm:MapPushpin.LocationChangedAnimation>
                    </dxm:MapPushpin>
                <dxm:MapItemStorage>
            </dxm:VectorLayer>
        </dxm:MapControl>
    </Grid>
</Window>
csharp
using System.Windows;
using DevExpress.Xpf.Map;
using System;

namespace LocationAnimation {

    public partial class MainWindow : Window {
        Random rand = new Random((int)DateTime.Now.Ticks);

        public MainWindow() {
            InitializeComponent();
            SelectRandomLocation();
        }

        private void PushpinLocationAnimation_Completed(object sender, EventArgs e) {
            SelectRandomLocation();
        }

        void SelectRandomLocation() {
            pushpin.Location = (new GeoPoint(rand.NextDouble() * 40, rand.NextDouble() * 40));
        }
    }
}
vb
Imports Microsoft.VisualBasic
Imports System.Windows
Imports DevExpress.Xpf.Map
Imports System

Namespace LocationAnimation

    Partial Public Class MainWindow
        Inherits Window
        Dim rand As Random = New Random(CInt(DateTime.Now.Millisecond))

        Public Sub New()
            InitializeComponent()
            SelectRandomLocation()
        End Sub

        Private Sub PushpinLocationAnimation_Completed(ByVal sender As Object, ByVal e As EventArgs)
            SelectRandomLocation()
        End Sub

        Private Sub SelectRandomLocation()
            pushpin.Location = (New GeoPoint(rand.NextDouble() * 40, rand.NextDouble() * 40))
        End Sub
    End Class
End Namespace

Inheritance

Object DispatcherObject DependencyObject Freezable MapDependencyObject MapItem MapPushpin

See Also

MapPushpin Members

DevExpress.Xpf.Map Namespace