메뉴 건너뛰기

프로그램언어

조회 수 18634 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="generator" content="kimsQ">
<meta name="author" content="<?=$browse['name']?>">
<meta name="keywords" content="<?=$browse['title']?> <?=$R['tag']?>">
<title>네이버 맵</title>
</head>
<body  leftmargin=0 topmargin=0 marginwidth=0 >
<?
function getUTF_8($str)
{
return iconv('EUC-KR','UTF-8',$str);
}

function getEUC_KR($str)
{
return iconv('UTF-8','EUC-KR',$str);
}

function getnavermapXml2($navermapxml_url,&$ygeopoint_x,&$ygeopoint_y){
$pquery = $navermapxml_url;
$fp = fsockopen ("maps.naver.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)";
} else {
fputs($fp, "GET /api/geocode.php?");
fputs($fp, $pquery);
fputs($fp, " HTTP/1.1\r\n");
fputs($fp, "Host: maps.naver.com\r\n");
fputs($fp, "Connection: Close\r\n\r\n");

$header = "";
while (!feof($fp)) {
$out = fgets ($fp,512);
if (trim($out) == "") {
break;
}
$header .= $out;
}

$mapbody = "";
while (!feof($fp)) {
$out = fgets ($fp,512);
$mapbody .= getUTF_8($out);
}

$idx = strpos(strtolower($header), "transfer-encoding: chunked");

if ($idx > -1) { // chunk data
$temp = "";
$offset = 0;
do {
$idx1 = strpos($mapbody, "\r\n", $offset);
$chunkLength = hexdec(substr($mapbody, $offset, $idx1 - $offset));

if ($chunkLength == 0) {
break;
} else {
$temp .= substr($mapbody, $idx1+2, $chunkLength);
$offset = $idx1 + $chunkLength + 4;
}
} while(true);
$mapbody = $temp;
}
fclose ($fp);
 }
// 여기까지 주소 검색 xml 파싱

$map_x_point_1=explode("<x>", ($mapbody));
$map_x_point_2=explode("</x>", $map_x_point_1[1]);
$ygeopoint_x=$map_x_point_2[0];
$map_y_point_1=explode("<y>", ($mapbody));
$map_y_point_2=explode("</y>", $map_y_point_1[1]);
$ygeopoint_y=$map_y_point_2[0];
#
}//end function
#
$naver_mapkey = "/*이자리에 발급받은 코드를 입력하세요*/";//http://dev.naver.com/openapi/register 지도키 발급코드
//$addr <== 여기에 주소를 입력하거나 값을 넘겨주면 되겠지요
$navermapxml_url='key='.$naver_mapkey.'&query='.getUTF_8($addr);
#
getnavermapXml2($navermapxml_url,$ygeopoint_x,$ygeopoint_y);
?>
<!-- 네이버 지도 키 값 -->
<script type="text/javascript" src="http://map.naver.com/js/naverMap.naver?key=<?php echo $naver_mapkey?>"></script>
<!-- 네이버 지도 키 값 끝 -->
<style>
#mapcontainer{
width: <?php echo $map_width?>px;
height: <?php echo $map_height?>px;http://naver.com/
margin:0;
}
</style>
<div id="mapbody"></div>
<div id="display"></div>
<script type="text/javascript">

 var x_point = '<? echo ($ygeopoint_x)?$ygeopoint_x:0; ?>';
 var y_point = '<? echo ($ygeopoint_y)?$ygeopoint_y:0; ?>';
 /*
 * 지도API 2.0은 기존의 카텍 좌표 외에도 위경도 좌표를 지원합니다.
 * 위경도 좌표를 사용하기 위해서는 기존의 NPoint 클래스 대신 NLatLng 클래스를 사용해야 합니다.
 *
 * http://maps.naver.com/api/geocode.php 에서 "경기도성남시정자1동25-1"을 검색한 결과인
 * x : 321033, y : 529749
 * 를 예로 들어 설명해 보겠습니다.
 *
 * 편의를 위해 전역변수로 mapObj, tm128, latlng를 선언해 두었습니다.
 */
var mapObj = new NMap(document.getElementById('mapbody'),<?php echo $map_width?>,<?php echo $map_height?>);
var tm128 = new NPoint(x_point,y_point);
var latlng;
/*
 * 경기도성남시정자1동25-1의 위치로 이동합니다. 레벨은 1로 지정하였습니다.
 * 인덱스맵과 확대/축소 컨트롤러를 등록하고 마우스 줌인/아웃을 활성화 하였습니다.
 */
mapObj.setCenterAndZoom(tm128, <?php echo $yzoom?>);
mapObj.addControl(new NZoomControl());
mapObj.enableWheelZoom();
latlng = mapObj.fromTM128ToLatLng(tm128);
/*
 * NMark도 마찬가지로 tm128 대신 위경도를 사용하여 아이콘을 표시하였습니다.
 */
var mark = new NMark(latlng, new NIcon('../image/ic_spot.png',new NSize(52,41),new NSize(14,40)));
mapObj.addOverlay(mark);
</script>
</body>
</html>

List of Articles
번호 제목 날짜 조회 수
160 php 내장함수 2017.03.07 17001
159 www가 붙은 도메인과 안붙은 같은 도메인, 로그인 세션 유지 2017.03.07 17080
158 PHP 날짜/시간 정리 2017.03.07 18629
157 몫과 나머지 구하기 2017.03.07 18461
156 체크박스, post 로 넘기고 받아서 다시 체크하기, checkbox 2017.03.07 21125
155 파일 이름에서 확장자 추출마스터 2017.03.07 20061
154 http://홈주소/?mode=xxx 하는방법 2017.03.07 17642
153 기본적인 페이징 2017.03.07 24845
152 PHP 속도 테스트 20 가지 2017.03.06 18305
151 POST, GET으로 배열값 받기(직렬화) file 2017.03.06 23284
150 파일 업로드 (중복처리) 2017.03.06 20178
149 간단한 PHP 파일 업로드, 다운로드 구현 2017.03.06 28541
148 다중 도메인에 따른 접속방법 2017.03.06 19370
» 네이버 지도 API 연동 PHP 소스 2017.03.06 18634
146 게시판 페이징 기법과 개념 file 2017.03.06 17323
145 PHP 도메인 이름이나 웹문서 주소 알아내기 2017.03.06 17589
144 그누보드, 여분필드 사용팁 2017.03.06 17604
143 엑셀(*.xls) 화일을 PHP에서 읽기 2017.03.06 17471
142 PHP 날짜, 시간 관련 함수. date(), mktime() 2017.03.06 16707
141 잡다한 php 2017.03.06 18501
Board Pagination Prev 1 ... 5 6 7 8 9 10 11 12 13 14 ... 17 Next
/ 17

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved