0

I'm new to UWP MapControl currently. I have a simple problem when adding XAML children to map (instead of the regular map elements).

this is my code:

    private void MapRightTapped(MapControl sender, MapRightTappedEventArgs args)
    {
        Ellipse circle = new Ellipse() { Height = 20, Width = 20, Fill = new SolidColorBrush(Colors.Black)};
        sender.Children.Add(circle);

        Geopoint position = new Geopoint(new BasicGeoposition()
        {
            Latitude = args.Location.Position.Latitude,
            Longitude = args.Location.Position.Longitude,
            Altitude = 5000,

        });
        MapControl.SetLocation(circle, position);
        MapControl.SetNormalizedAnchorPoint(circle, new Point(0.5, 0.5));
     }

At first the point displayed correctly on the map. but after zooming or tilting the map, the circle appeared to be anchored at the surface altitude and NOT at altitude of 5000

Cœur
  • 37,241
  • 25
  • 195
  • 267
user3136572
  • 134
  • 10

1 Answers1

3

You need to set an altitude reference system. Leaving it set to the default of unspecified will cause the altitude value to be ignored.

Duncan Lawler
  • 1,772
  • 8
  • 13
  • i tried all altitude reference system in the enum the same behavior :/, further more even when adding MapIcon where you can't set this property the same behavior occurred. – user3136572 Jun 10 '17 at 07:47
  • 1
    Altitude is supported for both XAML children and MapIcons, but will only work in Road mode on Creator's Update. It works in Aerial mode on all Windows 10 versions. – Duncan Lawler Jun 12 '17 at 17:32
  • For XAML you would do this: Ellipse circle = new Ellipse() { Height = 20, Width = 20, Fill = new SolidColorBrush(Colors.Black) }; MyMapControl.Children.Add(circle); Geopoint position = new Geopoint(new BasicGeoposition() { Latitude = 47.2, Longitude = -121.8, Altitude = 10000, }, AltitudeReferenceSystem.Ellipsoid); MapControl.SetLocation(circle, position); MapControl.SetNormalizedAnchorPoint(circle, new Point(0.5, 0.5)); – Duncan Lawler Jun 12 '17 at 17:42
  • MapIcon you would do this: var poiLocation = new Geopoint(new BasicGeoposition { Latitude = 47.643496, Longitude = -122.138343, Altitude = 5000 }, AltitudeReferenceSystem.Surface); this.myMapIcon = new MapIcon { Location = poiLocation, }; this.MyMapControl.MapElements.Add(this.myMapIcon); – Duncan Lawler Jun 12 '17 at 17:44