Get coordinates from town via google maps api in php

I have a list of users and their adresses in my database. I want to run a cronjob to get the cooridnates from their town. Is there any way, to send a request to the Google Maps Api and get a response with the coordinates?



curl is helper function for cURL.. Extract from some script...

$address = str_replace(" ", "+", $_GET["address"]);
$data = curl("$address&sensor=false");
$data = json_decode($data, true);
$json["city"] = $data["results"][0]["address_components"][2]["long_name"];
$json["country"] = $data["results"][0]["address_components"][3]["long_name"];
$json["iso"] = strtolower($data["results"][0]["address_components"][3]["short_name"]);
$json["ll"] = $data["results"][0]["geometry"]["location"]["lat"].",".$data["results"][0]["geometry"]["location"]["lng"];
echo json_encode($json);

Category:google maps Time:2011-07-17 Views:1

Related post

Copyright (C), All Rights Reserved.

processed in 0.978 (s). 13 q(s)