Reputation: 30558
My Application is a php program, and I only have the address name, instead of the coordination on the map. But I find that the google map API requires the coordination to pin the address. How can I do so? Thank you.
I have the address:'觀塘%20牛頭角%20創業街%202號%20美亞工業大廈%202樓%202A%20202室'. It can be search, and pin on the google map application, but when I using the google api to do geocoding, it shows me ZERO_RESULT:
Upvotes: 0
Views: 228
Reputation: 40193
The address can't be found then. Try simplifying the address or switching things around so maybe Google will understand better. Also check for mistakes in your address string.
Upvotes: 0
Reputation: 17886
Just convert the address into lat/lon first. You can either do this using javascript or you can use PHP (and cache it for later). Here is a simplified function to do that for you
function postcode_to_latlon($postcode){
$xml = simplexml_load_file('http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address='.$postcode);
$lat = $xml->result->geometry->location->lat;
$lon = $xml->result->geometry->location->lng;
return array($lat, $lon);
}
This process is called geocoding.
Upvotes: 1