我正在开发一个显示 SF MUNI 停止和时间的 Windows Phone 7 应用程序。我已经发布了它,但想添加地图功能。因此,我添加了一张地图,其中显示了特定用户选择路线的停靠点(入站或出站)。这是我的代码,它可以工作并显示路线上的每个站点:
//coords is an array of GeoCoordinates for each stop
//limit is the number of stops
GeoCoordinate [] coords=new GeoCoordinate[limit];
//pin is an array of Pushpins for each stop to add to the map
Pushpin[] pin = new Pushpin[limit];
for (int i = 0; i < limit; i++)
{
pin[i] = new Pushpin();
}
for (int i = 0; i < limit; i++)
{
coords[i] = new GeoCoordinate(Convert.ToDouble(latitude[inb[i]]), Convert.ToDouble(longitude[inb[i]]));//populate coords array
pin[i].Location = coords[i];//assign coords to pushpin location for each stop
}
//wires up event handler for clicking on each stop
for (int i = 0; i < limit; i++)
{
pin[i].MouseLeftButtonUp += new MouseButtonEventHandler(pin_MouseLeftButtonUp);
}
//Adds a pin at each stop's geocoords for each station
for (int i = 0; i < limit; i++)
map1.Children.Add(pin[i]);
因此,上面的代码确实在每个地理坐标上正确放置了图钉。我完全被难住了,如果我按下图钉,我如何获得该图钉的地理坐标?换句话说,当我按下图钉时,我想在某个变量中捕获 pin[i].Location (这是一个地理坐标)。
谢谢,我希望这能解释我的问题。
阿曼达