Created
December 8, 2013 17:13
-
-
Save eskim/7860384 to your computer and use it in GitHub Desktop.
PHP naver geocode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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