Bing Map on Windows Phone - add click events to pushpins; display more details
Posted
by
Will Gill
on Stack Overflow
See other posts from Stack Overflow
or by Will Gill
Published on 2011-08-31T20:26:14Z
Indexed on
2012/11/27
17:04 UTC
Read the original article
Hit count: 258
I have a WP Phone app using a Bing Map control. I have an array of objects, and each object has a location. I iterate the array to place the pins on the map (see below). I have a touch event bound to each pin to allow the user to tap the pin to start an action.
Now - I would like, on tap, to show information from the object that relates to that pin to be shown in a textbox. How can I retrieve the object from the array that corresponds to the pushpin that was tapped/clicked?
foreach (wikiResult result in arrayResults)
{
double lat = double.Parse(result.Latitude, CultureInfo.InvariantCulture);
double lng = double.Parse(result.Longitude, CultureInfo.InvariantCulture);
statusTextBlock.Text = result.Latitude + " " + result.Longitude + " " + lat + " " + lng;
GeoCoordinate d = new GeoCoordinate(lat, lng);
Pushpin pin;
pin = new Pushpin();
pin.Location = d;
pin.Content = result.Name;
pin.MouseLeftButtonUp += new MouseButtonEventHandler(pin1_MouseLeftButtonUp);
myMap.Children.Add(pin);
}
void pin1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
//display the content from the object in a text box
}
Many thanks in advance!
© Stack Overflow or respective owner