Posted By

adampatterson on 09/09/10


Tagged

php data post google xml code csv api addressbook explode 5


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

msheflin


How to use Google HTTP Geocoding


 / Published in: PHP
 

URL: http://www.adampatterson.ca/blog/2010/09/google-http-geocoding/

  1. $address = '1 Sir Winston Churchill Square';
  2. $city = 'edmonton';
  3. $province = 'alberta';
  4. $country = 'canada';
  5. $postalcode = 'T5J 2R7';
  6.  
  7. // Google Geo Address
  8. $googleAddress = "http://maps.google.com/maps/geo?q=".urlencode($address) .'+'. urlencode($city) .'+'. urlencode($province).'+'. urlencode($postalcode).'+'. urlencode($country)."&output=xml";
  9.  
  10. // Retrieve the URL contents
  11. $googlePage = file_get_contents($googleAddress);
  12.  
  13. // Parse the returned XML file
  14. $xml = new SimpleXMLElement($googlePage);
  15.  
  16. // Parse the coordinate string
  17. list($longitude, $latitude, $altitude) = explode(",", $xml->Response->Placemark->Point->coordinates);
  18.  
  19. // Output the coordinates
  20. echo "Longitude: $longitude, Latitude: $latitude";

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Rachaelwooten on July 1, 2017

Geocoding is the method of changing addresses into geographic coordinates which you can use on an online map like students [url=http://www.assignmentlabs.co.uk]pay someone to write my assignment[/url]. It also converts geographic locations into a human-readable address. Additionally you can use Google geocoding to find the address of any given place identity directly via an HTTP request.

Posted By: Rachaelwooten on July 1, 2017

Geocoding is the method of changing addresses into geographic coordinates which you can use on an online map like students <a href="http://www.assignmentlabs.co.uk>pay someone to write my assignment . It also converts geographic locations into a human-readable address. Additionally you can use Google geocoding to find the address of any given place identity directly via an HTTP request.

Posted By: Rachaelwooten on July 1, 2017

Geocoding is the method of changing addresses into geographic coordinates which you can use on an online map like students

<a href="http://www.assignmentlabs.co.uk>pay someone to write my assignment

. It also converts geographic locations into a human-readable address. Additionally you can use Google geocoding to find the address of any given place identity directly via an HTTP request.

Posted By: Rachaelwooten on July 1, 2017

Geocoding is the method of changing addresses into geographic coordinates which you can use on an online map like students

<a href="http://www.assignmentlabs.co.uk>pay someone to write my assignment

. It also converts geographic locations into a human-readable address. Additionally you can use Google geocoding to find the address of any given place identity directly via an HTTP request.

Posted By: Rachaelwooten on July 1, 2017

Geocoding is the method of changing addresses into geographic coordinates which you can use on an online map like students

You need to login to post a comment.