2016-11-03 11 views
0

MapLocationFinderResultリストから複数の項目を取得しようとすると、困惑します。 私は、foreachループを使用して試してみた:C#MapLocationFinderResultを繰り返します。

private async void GetRouteAndDirections() 
    { 
     // Query hint 
     queryHint = new BasicGeoposition(); 
     queryHint.Latitude = -37.8136; 
     queryHint.Longitude = 144.9631; 
     Geopoint hintPoint = new Geopoint(queryHint); 

     // Start 
     //BasicGeoposition startLocation = new BasicGeoposition(); 
     result = await MapLocationFinder.FindLocationsAsync(addressToGeocode, hintPoint, 10); 

     // End 

     // Get route 

     // Show 
     if (result.Status == MapLocationFinderStatus.Success) 
     { 
      foreach (MapLocation i in result.Locations) 
      { 
       txtMessage.Text += (result.Locations[i].Address.Street + " \n"); // need to figure out how to iterate over this 
      } 

      AddMapIcon(); 
     } 

エラーは次のとおりです。

重大度コード説明プロジェクトファイルの行抑制状態 エラーCS1503引数1:はWindows.Services.Maps」から変換することはできませんint型 MapsApp C「から '.MapLocation:\ Users \ユーザーロバート\ OneDrive \ VSProjects \ MapsApp \ MapsApp \ MainPage.xaml.csは72アクティブ

私は何とか、それをキャストしようとするべきでしょうか?

これはWindows.Services.Mapsを使用しています。 Windows.Devices.Geolocation; Windows.UI.Xaml.Controls.Maps

答えて

0

iMapLocationですが、インデックスとして使用しようとしています。このコードを試してください:

foreach (MapLocation i in result.Locations) 
{ 
    txtMessage.Text += (i.Address.Street + " \n"); 
} 
+0

ありがとうございました! – ionside

関連する問題