Skip to content

Instantly share code, notes, and snippets.

@eskim
Created December 8, 2013 17:13
Show Gist options
  • Save eskim/7860384 to your computer and use it in GitHub Desktop.
Save eskim/7860384 to your computer and use it in GitHub Desktop.
PHP naver geocode
public static function nhnGeocode($addr)
{
return Cache::sear('geocode.'.$addr, function() use($addr){
$api_key = Config::get('3rdparty.naver_api_key');
$result_xml = File::getRemote("http://openapi.map.naver.com/api/geocode.php?key=$api_key&encoding=utf-8&coord=latlng&query=" . $addr);
$xml = new SimpleXMLElement($result_xml);
$lng = $xml->item[0]->point->x;
$lat = $xml->item[0]->point->y;
return array('lat' => (string)$lat, 'lng' => (string)$lng);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment