Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i add a pushpin to a Windows Phone 8.1 Map Control?

I've been looking for examples on how to perform this task however i haven't been able to find a clear one. Can someone please point me in the right direction. I'm lost...

Edit/Update:

Ive manage to add some markers following the following example: http://www.microsoftvirtualacademy.com/Content/ViewContent.aspx?et=8698&m=8686&ct=29035

However, as MSDN documentation states,

The MapIcon is not guaranteed to be shown. It may be hidden when it obscures other elements or labels on the map. The optional Title of the MapIcon is not guaranteed to be shown. If you don't see the text, zoom out by increasing the value of the ZoomLevel property of the MapControl.

I need something that its going to show no matter what, it has been almost impossible to find an simple example on how to perform this simple task! I must say im using the latest Maps sdk, not the previous 8.0.

like image 719
Salvador Molina Avatar asked Dec 26 '22 05:12

Salvador Molina


1 Answers

I was able to do it using the following code

   public void AddPushpin(BasicGeoposition location, string text)
        {
            var pin = new Grid()
            {
                Width = 50,
                Height = 50,
                Margin = new Windows.UI.Xaml.Thickness(-12)
            };

            pin.Children.Add(new Ellipse()
            {
                Fill = new SolidColorBrush(Colors.DodgerBlue),
                Stroke = new SolidColorBrush(Colors.White),
                StrokeThickness = 3,
                Width = 50,
                Height = 50
            });

            pin.Children.Add(new TextBlock()
            {
                Text = text,
                FontSize = 12,
                Foreground = new SolidColorBrush(Colors.White),
                HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center,
                VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center
            });

            MapControl.SetLocation(pin, new Geopoint(location));
            Map_MainMap.Children.Add(pin);
        }
like image 104
Salvador Molina Avatar answered Dec 28 '22 00:12

Salvador Molina