2

pin1 と pin2 の 2 つの画鋲があります。デフォルトの黒い画像を自分の画像に変更するにはどうすればよいですか? 助けてください。ありがとう

4

1 に答える 1

9

すべての画鋲機能が必ずしも必要でない場合は、 を使用してImageに追加できます。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);

特定の Pushpin 機能が必要な場合は、PushPin テンプレートを使用する別のオプションがあります。

Pushpin pushpin = new Pushpin();
pushpin.Template = Application.Current.Resources["PushPinTemplate"]  
    as (ControlTemplate);

次に、アプリケーション リソース XAML で、次のようにテンプレートを定義できます。

<ControlTemplate x:Key="PushPinTemplate">
    <Grid>
        <Rectangle Width="32" Height="32">
            <Rectangle.Fill>
               <ImageBrush BitmapSource="YOUR IMAGE URL" /> 
            </Rectangle.Fill>
        </Rectangle>
    </Grid>
</ControlTemplate>
于 2013-01-28T10:17:19.873 に答える