Bing maps rest api in windows phone 7

by sunil ravulapalli /25. October 2010 22:30 /windows-phone /Comments (0)

Get a Bing maps developer account here so that you can get your own Bing maps key.
If you want to get the route between two points, the code to call the web service looks like this:

 string bingUri
 string homeAddress;
 string workAddress;
 string fullUri;
 const string bingKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

 fullUri = String.Format(bingUri,homeAddress,workAddress,bingKey,"time" );
 WebClient proxy = new WebClient();
 proxy.OpenReadCompleted += 
     new OpenReadCompletedEventHandler(proxy_OpenReadCompleted);
 proxy.OpenReadAsync(new Uri(fullUri));

proxy_OpenReadCompleted looks like this: (The following code also extracts traffic information)

uction = instruction; this.warnings = warnings; } } public class Warning { public string severity; public string desc; public Warning(string severity, string desc) { this.severity = severity; this.desc = desc; } }

If you want to loop through the results use this model:

foreach (ItineraryItem itineraryItem in itineraryItems)
  foreach (Warning warning in itineraryItem.warnings)

You can find more options for REST API here:

blog comments powered by Disqus