Advertisement
Guest User

Untitled

a guest
Sep 8th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using ConsoleApplication21.net.virtualearth.dev;
  5.  
  6. namespace ConsoleApplication21
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. net.virtualearth.dev.GeocodeService serv = new ConsoleApplication21.net.virtualearth.dev.GeocodeService();
  13. var x = new ConsoleApplication21.net.virtualearth.dev.GeocodeRequest();
  14. System.Net.NetworkCredential credentials = new System.Net.NetworkCredential();
  15.  
  16. credentials.UserName = "150009";
  17. credentials.Password = "Matchbox-GPS10";
  18. serv.Credentials = credentials;
  19. var rtn = GeocodeAddress("33 Wellstone gardens");
  20. Console.Write("");
  21.  
  22. }
  23. private static String GeocodeAddress(string address)
  24. {
  25. string results = "As34jwBKUSUoXNWPXC1l2PvR8ik3jeskMEW6oXZdsuRaNPIV_GP4";
  26. string key = "insert your Bing Maps key here";
  27. GeocodeRequest geocodeRequest = new GeocodeRequest();
  28.  
  29. // Set the credentials using a valid Bing Maps key
  30. geocodeRequest.Credentials = new Credentials();
  31. geocodeRequest.Credentials.ApplicationId = key;
  32.  
  33. // Set the full address query
  34. geocodeRequest.Query = address;
  35.  
  36. // Set the options to only return high confidence results
  37. ConfidenceFilter[] filters = new ConfidenceFilter[1];
  38. filters[0] = new ConfidenceFilter();
  39. filters[0].MinimumConfidence = Confidence.High;
  40.  
  41. // Add the filters to the options
  42. GeocodeOptions geocodeOptions = new GeocodeOptions();
  43. geocodeOptions.Filters = filters;
  44. geocodeRequest.Options = geocodeOptions;
  45.  
  46. // Make the geocode request
  47. GeocodeServiceClient geocodeService = new GeocodeServiceClient();
  48. GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest);
  49.  
  50. if (geocodeResponse.Results.Length > 0)
  51. results = String.Format("Latitude: {0}\nLongitude: {1}",
  52. geocodeResponse.Results[0].Locations[0].Latitude,
  53. geocodeResponse.Results[0].Locations[0].Longitude);
  54. else
  55. results = "No Results Found";
  56.  
  57. return results;
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement