List Info

Thread: geocode service unavailable error?




geocode service unavailable error?
user name
2006-10-03 18:00:27

I am using a function to get the latitude and longitude of an address.
i really like the way that Yahoo handles this since it will give you
a result even if the street address is not found.

Today, while testing my script, I got an error that the service was
unavailable. Entering the URL directly in the browser gave me the
same error. It appears to be working properly now.

I'm new to this stuff, so how often does the Yahoo geocode service
have issues? Also, how can I capture the error and handle it before
it throws an error to the browser? I have written it in php. The
function is (note; I am using my own appid value but I replced it here
for reference.):

function YahooGeo($location) {
$location = preg_replace("/#/", "", $location);
$location = preg_replace("/&/";, "", $location);
$location = preg_replace("/'/", "", $location);
$q = 'http://api.local.yahoo.com/MapsService/V1/geocode';
$q .= '?appid=YahooDemo&;location='.rawurlencode($location);

$resultfile = fopen($q,"r";);
$result = fread($resultfile, 64000);
// Now we have to search for the lat and lon in the returned xml code
$begintag=strpos($result,"<Latitude>&quot;);
$endtag=strpos($result,"&lt;/Latitude>";);
$lat=substr($result,$begintag&#43;10,$endtag-$begintag-10);

$begintag=strpos($result,&quot;<Longitude>&quot;);
$endtag=strpos($result,"&lt;/Longitude>&quot;);
$lon=substr($result,$begintag&#43;11,$endtag-$begintag-11);

$loc[";lat"] = $lat;
$loc[";lon"] = $lon;

return $loc;
}

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )