2014-01-18 80 views
0

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

    } 
} 

回答

0

的BingMapsTask設計推出了Bing地圖應用的記錄在這裏:http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.tasks.bingmapstask(v=vs.105).aspx

如果我正確理解你的要求,你要的地圖添加到您的應用程序和地理編碼位置,並顯示他們在地圖上無需離開你的應用程序要做到這一點,你需要一個地圖添加到您的應用程序文件的位置:http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207045(v=vs.105).aspx

然後,您可以使用地理編碼的GeocodeQuery您的查詢作爲記錄在這裏:http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj244363(v=vs.105).aspx