Advertisement
Guest User

Untitled

a guest
May 18th, 2013
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.24 KB | None | 0 0
  1. private void GetLatLongFromAddress(string street, string city, string state)
  2. {
  3. string geocoderUri = string.Format(@"http://rpc.geocoder.us/service/rest?address={0},{1},{2}", street, city, state);
  4. XmlDocument geocoderXmlDoc = new XmlDocument();
  5. geocoderXmlDoc.Load(geocoderUri);
  6. XmlNamespaceManager nsMgr = new XmlNamespaceManager(geocoderXmlDoc.NameTable);
  7. nsMgr.AddNamespace("geo", @"http://www.w3.org/2003/01/geo/wgs84_pos#");
  8. string sLong = geocoderXmlDoc.DocumentElement.SelectSingleNode(@"//geo:long", nsMgr).InnerText;
  9. string sLat = geocoderXmlDoc.DocumentElement.SelectSingleNode(@"//geo:lat", nsMgr).InnerText;
  10.  
  11. Latitude = Double.Parse(sLat);
  12. Longitude = Double.Parse(sLong);
  13. }
  14.  
  15. http://dev.virtualearth.net/REST/v1/Locations/CA/adminDistrict/postalCode/locality/addressLine?includeNeighborhood=includeNeighborhood&key=BingMapsKey
  16.  
  17. http://dev.virtualearth.net/REST/v1/Locations/US/1125%20E.%20102nd%20Street,%20Los%20Angeles,%20CA?key=Ai9-KNy6Al-r_ueyLuLXFYB_GlPl-c-_iYtu16byW86qBx9uGbsdJpwvrP4ZUdgD
  18.  
  19. {
  20. "authenticationResultCode":"ValidCredentials",
  21. "brandLogoUri":"http://dev.virtualearth.net/Branding/logo_powered_by.png",
  22. "copyright":"Copyright © 2012 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
  23. "resourceSets":[
  24. {
  25. "estimatedTotal":1,
  26. "resources":[
  27. {
  28. "__type":"Location:http://schemas.microsoft.com/search/local/ws/rest/v1",
  29. "bbox":[
  30. 33.940492293415652,
  31. -118.26180800227225,
  32. 33.948217728557005,
  33. -118.24939194889963
  34. ],
  35. "name":"1125 E 102ND St, Los Angeles, CA 90002",
  36. "point":{
  37. "type":"Point",
  38. "coordinates":[
  39. 33.944355010986328,
  40. -118.25559997558594
  41. ]
  42. },
  43. "address":{
  44. "addressLine":"1125 E 102ND St",
  45. "adminDistrict":"CA",
  46. "adminDistrict2":"Los Angeles Co.",
  47. "countryRegion":"United States",
  48. "formattedAddress":"1125 E 102ND St, Los Angeles, CA 90002",
  49. "locality":"Los Angeles",
  50. "postalCode":"90002"
  51. },
  52. "confidence":"High",
  53. "entityType":"Address",
  54. "geocodePoints":[
  55. {
  56. "type":"Point",
  57. "coordinates":[
  58. 33.944355010986328,
  59. -118.25559997558594
  60. ],
  61. "calculationMethod":"Parcel",
  62. "usageTypes":[
  63. "Display"
  64. ]
  65. },
  66. {
  67. "type":"Point",
  68. "coordinates":[
  69. 33.944118499755859,
  70. -118.25559997558594
  71. ],
  72. "calculationMethod":"Interpolation",
  73. "usageTypes":[
  74. "Route"
  75. ]
  76. }
  77. ],
  78. "matchCodes":[
  79. "Good"
  80. ]
  81. }
  82. ]
  83. }
  84. ],
  85. "statusCode":200,
  86. "statusDescription":"OK",
  87. "traceId":"81518ba504a3494bb0b62bdb6aa4b291|LTSM002104|02.00.83.500|LTSMSNVM001473, LTSMSNVM001463, LTSMSNVM001452, LTSMSNVM001851, LTSMSNVM001458, LTSMSNVM001462"
  88. }
  89.  
  90. http://dev.virtualearth.net/REST/v1/Locations/US/1125%20E.%20102nd%20Street,%20Los%20Angeles,%20CA?o=xml&key=Ai9-KNy6Al-r_ueyLuLXFYB_GlPl-c-_iYtu16byW86qBx9uGbsdJpwvrP4ZUdgD
  91.  
  92. <Response>
  93. <Copyright>Copyright ? 2012 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.</Copyright>
  94. <BrandLogoUri>http://dev.virtualearth.net/Branding/logo_powered_by.png</BrandLogoUri>
  95. <StatusCode>200</StatusCode>
  96. <StatusDescription>OK</StatusDescription>
  97. <AuthenticationResultCode>ValidCredentials</AuthenticationResultCode>
  98. <TraceId>b9af8a6b058b455ca9c368b9e32142fe|LTSM002102|02.00.83.500|LTSMSNVM002001, LTSMSNVM001464, LTSMSNVM001451, LTSMSNVM001452, LTSMSNVM001457, LTSMSNVM002052, LTSMSNVM001461</TraceId>
  99. <ResourceSets>
  100. <ResourceSet>
  101. <EstimatedTotal>1</EstimatedTotal>
  102. <Resources>
  103. <Location>
  104. <Name>1125 E 102ND St, Los Angeles, CA 90002</Name>
  105. <Point>
  106. <Latitude>33.944355010986328</Latitude>
  107. <Longitude>-118.25559997558594</Longitude>
  108. </Point>
  109. <BoundingBox>
  110. <SouthLatitude>33.940492293415652</SouthLatitude>
  111. <WestLongitude>-118.26180800227225</WestLongitude>
  112. <NorthLatitude>33.948217728557005</NorthLatitude>
  113. <EastLongitude>-118.24939194889963</EastLongitude>
  114. </BoundingBox>
  115. <EntityType>Address</EntityType>
  116. <Address>
  117. <AddressLine>1125 E 102ND St</AddressLine>
  118. <AdminDistrict>CA</AdminDistrict>
  119. <AdminDistrict2>Los Angeles Co.</AdminDistrict2>
  120. <CountryRegion>United States</CountryRegion>
  121. <FormattedAddress>1125 E 102ND St, Los Angeles, CA 90002</FormattedAddress>
  122. <Locality>Los Angeles</Locality>
  123. <PostalCode>90002</PostalCode>
  124. </Address>
  125. <Confidence>High</Confidence>
  126. <MatchCode>Good</MatchCode>
  127. <GeocodePoint>
  128. <Latitude>33.944355010986328</Latitude>
  129. <Longitude>-118.25559997558594</Longitude>
  130. <CalculationMethod>Parcel</CalculationMethod>
  131. <UsageType>Display</UsageType>
  132. </GeocodePoint>
  133. <GeocodePoint>
  134. <Latitude>33.944118499755859</Latitude>
  135. <Longitude>-118.25559997558594</Longitude>
  136. <CalculationMethod>Interpolation</CalculationMethod>
  137. <UsageType>Route</UsageType>
  138. </GeocodePoint>
  139. </Location>
  140. </Resources>
  141. </ResourceSet>
  142. </ResourceSets>
  143. </Response>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement