sinjhan / php-google-map-api

Automatically exported from code.google.com/p/php-google-map-api
0 stars 0 forks source link

Yahoo Placefinder Geocoding #95

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Here's working Code for Geolocation via YAHOO Placefinder API:

// Yahoo Geocoding API
// Compose YQL query
$_yql_query = 'select * from geo.placefinder where text = "' . str_replace('"', 
'\"', $address) . '"';
// Compose URL
$_url = 'http://query.yahooapis.com/v1/public/yql';
$_url .= '?q=' . rawurlencode($_yql_query);
$_url .= '&format=json';
// Make HTTP call and process result
if($_result = $this->fetchURL($_url)) {
  $_result_parts = json_decode($_result);
  if(isset($_result_parts->error) || !isset($_result_parts->query->results)){
    return false;
  }
  $_coords['lat'] = (float) $_result_parts->query->results->Result->latitude;
  $_coords['lon'] = (float) $_result_parts->query->results->Result->longitude;
  $_result = true;
}

I wrote this some time ago for an much older version og GoogleMapAPI, but it 
should be straightforward to integrate. The puplic api for non commercial use 
is limited to 2000 queries/day.

See http://developer.yahoo.com/boss/geo/docs/free_YQL.html for more info.

Original issue reported on code.google.com by Felix.Bu...@gmail.com on 19 Mar 2014 at 11:04