I have 2 pushpins, pin1 and pin2. How do I change the default black image to my own image? Please help. Thanks
Asked
Active
Viewed 5,593 times
1 Answers
9
You could use a Image
and add it to a MapLayer
if you don't necesserily need all pushpin functionality.
Example:
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);
If you do need have certain Pushpin functionality, another option is to use the PushPin template:
Pushpin pushpin = new Pushpin();
pushpin.Template = Application.Current.Resources["PushPinTemplate"]
as (ControlTemplate);
Then in your application resources XAML , you can define the template like this:
<ControlTemplate x:Key="PushPinTemplate">
<Grid>
<Rectangle Width="32" Height="32">
<Rectangle.Fill>
<ImageBrush BitmapSource="YOUR IMAGE URL" />
</Rectangle.Fill>
</Rectangle>
</Grid>
</ControlTemplate>

Leon Lucardie
- 9,541
- 4
- 50
- 70
-
2I added the above mentioned code using mapLayer for my code, but it does not show any pushpin on Map, any suggestions why it is not working? – Chamila Wijayarathna Dec 25 '13 at 12:18