mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-17 02:10:02 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@585 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
3958be025e
commit
a457add255
12 changed files with 186 additions and 139 deletions
|
|
@ -11,6 +11,9 @@
|
|||
var $upload_target_srl = 0;
|
||||
var $component_path = '';
|
||||
|
||||
// 네이버맵 openapi 키 값
|
||||
var $open_api_key = 'fb697bbfd01b42ab26db22162e166842';
|
||||
|
||||
/**
|
||||
* @brief upload_target_srl과 컴포넌트의 경로를 받음
|
||||
**/
|
||||
|
|
@ -34,6 +37,54 @@
|
|||
return $oTemplate->compile($tpl_path, $tpl_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief naver map open api에서 주소를 찾는 함수
|
||||
**/
|
||||
function search_address() {
|
||||
$address = Context::get('address');
|
||||
if(!$address) return new Object(-1,'msg_not_exists_addr');
|
||||
|
||||
Context::loadLang($this->component_path."lang");
|
||||
|
||||
// 지정된 서버에 요청을 시도한다
|
||||
$query_string = iconv("UTF-8","EUC-KR",sprintf('/api/geocode.php?key=%s&query=%s', $this->open_api_key, $address));
|
||||
|
||||
$fp = fsockopen('maps.naver.com', 80, $errno, $errstr);
|
||||
if(!$fp) return new Object(-1, 'msg_fail_to_socket_open');
|
||||
|
||||
fputs($fp, "GET {$query_string} HTTP/1.0\r\n");
|
||||
fputs($fp, "Host: maps.naver.com\r\n\r\n");
|
||||
|
||||
$buff = '';
|
||||
while(!feof($fp)) {
|
||||
$str = fgets($fp, 1024);
|
||||
if(trim($str)=='') $start = true;
|
||||
if($start) $buff .= trim($str);
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
|
||||
$buff = trim(iconv("EUC-KR", "UTF-8", $buff));
|
||||
$buff = str_replace('<?xml version="1.0" encoding="euc-kr" ?>', '', $buff);
|
||||
|
||||
$oXmlParser = new XmlParser();
|
||||
$xml_doc = $oXmlParser->parse($buff);
|
||||
|
||||
$addrs = $xml_doc->geocode->item;
|
||||
if(!is_array($addrs)) $addrs = array($addrs);
|
||||
$addrs_count = count($addrs);
|
||||
|
||||
$address_list = array();
|
||||
for($i=0;$i<$addrs_count;$i++) {
|
||||
$item = $addrs[$i];
|
||||
|
||||
$address_list[] = sprintf("%s,%s,%s", $item->point->x->body, $item->point->y->body, $item->address->body);
|
||||
|
||||
}
|
||||
|
||||
$this->add("address_list", implode("\n", $address_list));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에디터 컴포넌트가 별도의 고유 코드를 이용한다면 그 코드를 html로 변경하여 주는 method
|
||||
*
|
||||
|
|
@ -41,25 +92,27 @@
|
|||
* DocumentModule::transContent() 에서 해당 컴포넌트의 transHtml() method를 호출하여 고유코드를 html로 변경
|
||||
**/
|
||||
function transHTML($xml_obj) {
|
||||
/*
|
||||
$src = $xml_obj->attrs->src;
|
||||
|
||||
$x = $xml_obj->attrs->x;
|
||||
$y = $xml_obj->attrs->y;
|
||||
$width = $xml_obj->attrs->width;
|
||||
if(!$width) $width = 640;
|
||||
|
||||
$height = $xml_obj->attrs->height;
|
||||
if(!$height) $height = 480;
|
||||
$id = "navermap".rand(11111111,99999999);
|
||||
|
||||
$auto_start = $xml_obj->attrs->auto_start;
|
||||
if($auto_start!="true") $auto_start = "false";
|
||||
else $auto_start = "true";
|
||||
$body_code = sprintf('<div id="%s" style="width:%spx;height:%spx;">%s', $id, $width, $height,"\n");
|
||||
$footer_code =
|
||||
sprintf(
|
||||
'<script type="text/javascript"> '.
|
||||
'var mapObj = new NMap(xGetElementById("%s")); '.
|
||||
'mapObj.addControl(new NSaveBtn()); '.
|
||||
'mapObj.setCenterAndZoom(new NPoint(%d,%d),3); '.
|
||||
'mapObj.enableWheelZoom(); '.
|
||||
'</script>',
|
||||
$id, $x, $y
|
||||
);
|
||||
|
||||
$caption = $xml_obj->body;
|
||||
|
||||
$src = str_replace(array('&','"'), array('&','&qout;'), $src);
|
||||
|
||||
return sprintf("<div><script type=\"text/javascript\">displayMultimedia(\"%s\", \"%s\",\"%s\",%s);</script>", $src, $width, $height, $auto_start);
|
||||
*/
|
||||
Context::addJsFile("http://maps.naver.com/js/naverMap.naver?key=".$this->open_api_key);
|
||||
Context::addHtmlFooter($footer_code);
|
||||
return $body_code;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue