我正在寫一個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();
}
}
}