I am trying to create a simple php function that utilizes the
Geocoding API V3 web service.  I have posted sample code below. I
hardcoded an
address in there to show an example of the format of the variable
being passed in. I cannot figure out why this function fails.  The xml
just comes back blank.
Any suggestions would be greatly appreciated.

function geocodeAddress($address){
                $address = "1600 Amphitheatre Parkway Mountain View CA";
                define("MAPS_HOST", "maps.google.com");
                $base_url = "http://"; . MAPS_HOST . "/maps/api/geocode/xml";
                $request_url = $base_url . "?address=" . urlencode($address) .
"&sensor=false";
                $xml = simplexml_load_file($request_url) or die("url not 
loading");

                $status = $xml->GeocodeResponse->status;
                if ($status == "OK") {
                        // Successful geocode
                        $lat = $xml->GeocodeResponse->geometry->location->lat;
                        $lng = $xml->GeocodeResponse->geometry->location->lng;
                        return $lat . "," . $lng;
                }else {
                        // failure to geocode
                        return ("failed");
                }
        }

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to