how can i get lat-/longitude of an address during an CSV-Import by PHP? I import addresses from a csv and save these into a mysql-table. During the import i've to verify the latitude/longitude of the adresse to save this information into the table too.
Code:
while ( ($data = fgetcsv ($handle, 1000, ";")) !== FALSE ) {
…
$adress = urlencode($data[4]).",".$data[5]."+".$data['6'];
$geocode=file_get_contents("http://maps.google.com/maps/api/geocode/json?address=".$adress."&sensor=false");
$output= json_decode($geocode);
$lat = $output->results[0]->geometry->location->lat;
$lng = $output->results[0]->geometry->location->png;
…
}
Error-Info: file_get_contents(http://maps.google.com/maps/api/geocode/json?address=Im+Chr%E4merhoger+10,8910+Affoltern am Albis&sensor=false) [function.file-get-contents.php]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in
Thanks for help/tips.
regards thomas
$lng = $output->results[0]->geometry->location->**png**;
?? – davidkonrad%20
s – davidkonrad