I have a scenario where I would like the user to view multiple pushpins in Bing maps in a wp7 app. I used maplayer to make the cluster of pushpins, but I could not add an image to that pushpin dynamically in the cs file itself. By the way, I have not used the pushpin control in xaml. I'm just adding the pushpin object to the maplayer while looping through.
Here is my code:
maplayer layer = new maplayer();
watcher.start();
for (int i = 0; i < lst.count; i++)
{
Pushpin mypin = new Pushpin();
watcher.Position.Location.Latitude = Convert.ToDouble(lst[i].Latitude);
watcher.Position.Location.Longitude=Convert.ToDouble(lst[i].Longitude);
}
GeoCoordinate geo = new GeoCoordinate(watcher.Position.Location.Latitude, watcher.Position.Location.Longitude);
mypin.Location = geo;
mypin.Background = new SolidColorBrush(Colors.Gray);
mypin.Foreground = new SolidColorBrush(Colors.White);
mypin.Content = "My location";
layer.AddChild(mypin, mypin.Location);
}
map1.SetView(watcher.Position.Location, Status == true ? 5.0 : 3.0);
map1.Children.Add(layer);
watcher.stop();
I have also tried using the image brush property to provide image source to pushpin but the pushpin itself goes invisible.
like this:
ImageBrush ib = new ImageBrush();
ib.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"Images/push.png", UriKind.Relative));
mypin.Background = ib;
Please help me on this. I need this to be done without changing/adding datatemplate to pushpin from the xaml side.