2014-01-18 28 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