如果你不需要所有的图钉功能,你可以使用a Image并将其添加到a MapLayer.
例:
MapLayer mapLayer = new MapLayer();
Image myPushPin = new Image();
myPushPin.Source = new BitmapImage(new Uri("YOUR IMAGE URL",UriKind.Relative));
myPushPin.Width = 32;
myPushPin.Height = 32;
mapLayer.AddChild(myPushPin, <LOCATION_OF_PIN>, PositionOrigin.Center);
bingMap.Children.Add(mapLayer);
Run Code Online (Sandbox Code Playgroud)
如果您确实需要某些Pushpin功能,另一个选项是使用PushPin模板:
Pushpin pushpin = new Pushpin();
pushpin.Template = Application.Current.Resources["PushPinTemplate"]
as (ControlTemplate);
Run Code Online (Sandbox Code Playgroud)
然后在您的应用程序资源XAML中,您可以像这样定义模板:
<ControlTemplate x:Key="PushPinTemplate">
<Grid>
<Rectangle Width="32" Height="32">
<Rectangle.Fill>
<ImageBrush BitmapSource="YOUR IMAGE URL" />
</Rectangle.Fill>
</Rectangle>
</Grid>
</ControlTemplate>
Run Code Online (Sandbox Code Playgroud)