I'm trying to use restful service with google maps to get the latitude and longitude of a given address.
function onBeforeWrite(){
$map = new RestfulService("http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false", 0);
$xmlResponse=$map->request()->getBody();
//$coordinates = $map->getValues($xmlResponse,"location");
//$lat = $map->getValues($xmlResponse,"GeocodeResponse_result_geometry_location","lat");
//$long = $map->getValues($xmlResponse,"result_geometry_location","lng");
parent::onBeforeWrite();
}
None of the commented getValues() above returns anything but null--obviously I've tried several different ways. The xml response is along the lines of (full response here):
<GeocodeResponse>
<status>OK</status>
<result>
<a lot of address components the same level as geometry></a lot of address components the same level as geometry>
<a lot of address components the same level as geometry></a lot of address components the same level as geometry>
<geometry>
<location>
<lat>37.4217550</lat>
<lng>-122.0846330</lng>
</location>
<location_type>ROOFTOP</location_type>
<viewport>
<southwest>
<lat>37.4188514</lat>
<lng>-122.0874526</lng>
</southwest>
<northeast>
<lat>37.4251466</lat>
<lng>-122.0811574</lng>
</northeast>
</viewport>
</geometry>
</result>
</GeocodeResponse>
What am i doing wrong?
Thank you!