Add Pushpin to MapControl in UWP

I would like to add a Pushpin to MapControl in a Windows 10 application, but it seems that control has passed with Windows 8.1.

Pushpin

It was that simple:

Pushpin locationPushpin = new Pushpin();                      
locationPushpin.Background = new SolidColorBrush(Colors.Purple);
locationPushpin.Content = "You are here";
locationPushpin.Tag = "locationPushpin";
locationPushpin.Location = watcher.Position.Location;
this.map.Children.Add(locationPushpin);
this.map.SetView(watcher.Position.Location, 18.0);

But the Pushpin type is no longer recognized ...

+4
source share
1 answer

UWP has slightly changed map management - look at the Windows.UI.Xaml.Controls.Maps namespace .

Regarding the addition of Pushpins (POIs), you can do this in several ways . For example:

// get position
Geopoint myPoint = new Geopoint(new BasicGeoposition() { Latitude = 51, Longitude = 0 });
//create POI
MapIcon myPOI = new MapIcon { Location = myPoint, NormalizedAnchorPoint = new Point(0.5, 1.0), Title = "My position", ZIndex = 0 };
// add to map and center it
myMap.MapElements.Add(myPOI);
myMap.Center = myPoint;
myMap.ZoomLevel = 10;

Additional recommendations to visit MSDN .

+5
source

Source: https://habr.com/ru/post/1614836/


All Articles