2016-11-03 3 views
0

Ich bin ratlos beim Versuch, mehr als ein Element aus einer MapLocationFinderResult Liste zu bekommen. Ich habe versucht, eine foreach-Schleife:C# iterieren über 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(); 
     } 

Der Fehler ist:

Severity Code Beschreibung Projektdatei Zeilenunterdrückungszustand Fehler CS1503 Argument 1: von ‚Windows.Services.Maps nicht konvertieren .MapLocation‘auf 'int' MapsApp C: \ Benutzer \ Robert \ Microsoft Onedrive \ VSProjects \ MapsApp \ MapsApp \ MainPage.xaml.cs 72 Aktive

Soll ich es gegossen werden versuchen, irgendwie?

Dies verwendet Windows.Services.Maps; Windows.Devices.Geolocation; Windows.UI.Xaml.Controls.Maps

Antwort

0

i ist vom Typ MapLocation, aber Sie versuchen, es als Index zu verwenden. Versuchen Sie diesen Code:

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

Vielen Dank! – ionside