metalx1000

Google Maps JSON get address

Dec 1st, 2014
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $webclient = New-Object System.Net.WebClient
  2. $location="Disney"
  3.  
  4. Write-Output "Getting Address for $location"
  5. $url="https://maps.googleapis.com/maps/api/geocode/json?address=$location"
  6. $json=$webclient.DownloadString($url)
  7.  
  8. [System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
  9. $ser = New-Object System.Web.Script.Serialization.JavaScriptSerializer
  10. $obj = $ser.DeserializeObject($json)
  11. $item=$obj.Item("results")
  12.  
  13. $line_break="==============================================\n";
  14. $first=$item.Get(0).formatted_address
  15. Write-Output "$line_break First Entry $first\n$line_break"
  16.  
  17. Write-Output "$line_break All Entries\n$line_break"
  18. foreach($address in $item){
  19.     $address.formatted_address
  20. }
Add Comment
Please, Sign In to add comment