簡體   English   中英

在UWP中將Pushpin添加到MapControl

[英]Add Pushpin to MapControl in UWP

我想在Windows 10應用程序中向MapControl添加一個Pushpin,但似乎自Windows 8.1以來控件已經消失。

圖釘

它很簡單:

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);

但是不再識別圖釘類型......

UWP中的地圖控件幾乎沒有變化 - 請查看Windows.UI.Xaml.Controls.Maps命名空間

至於添加Pushpins(POI),你可以通過幾種方式完成 例如:

// 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;

有關更多指南, 請訪問MSDN

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM