我正在写一个windows phone应用程序,使用可视电话sdk给我输入地址的位置。我能够做到这一点(请看下面的代码),但它总是重定向到下一页的bing地图。但我想在同一页面添加地图和文本字段。我将在文本字段中输入位置,地图将显示位置(使用Visual Studio的bing地图)。有没有我可以参考的一些很好的例子。这将是一个很大的帮助。在c中查找位置bing地图#
namespace PhoneApp3
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
BingMapsTask bmt = new BingMapsTask();
GeoCoordinateWatcher gcw = new GeoCoordinateWatcher();
public MainPage()
{
InitializeComponent();
map1.CredentialsProvider = new ApplicationIdCredentialsProvider("Your API Key");
}
private void button1_Click(object sender, RoutedEventArgs e)
{
GeoCoordinate gc = new GeoCoordinate(47,-127);
bmt.Center = gc;
bmt.ZoomLevel = 9;
LocationRect.CreateLocationRect(gc);
bmt.Show();
//gcw.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(gcw_PositionChanged);
//gcw.Start();
}
void gcw_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
textBox1.Text = e.Position.Location.Latitude.ToString();
textBox2.Text = e.Position.Location.Longitude.ToString();
}
private void button2_Click(object sender, RoutedEventArgs e)
{
BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();
GeoCoordinate gc1 = new GeoCoordinate(47,-126);
GeoCoordinate gc2 = new GeoCoordinate(47, -127);
//LabeledMapLocation lml = new LabeledMapLocation("IIT Powai",)
LabeledMapLocation spaceNeedleLML = new LabeledMapLocation("",gc1);
LabeledMapLocation spaceNeedleLML2 = new LabeledMapLocation("",gc2);
bingMapsDirectionsTask.End = spaceNeedleLML;
bingMapsDirectionsTask.Start = spaceNeedleLML2;
// If bingMapsDirectionsTask.Start is not set, the user's current location is used as the start point.
bingMapsDirectionsTask.Show();
}
}
}