메뉴 건너뛰기

프로그램언어

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

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
<?php
    // 지도의 폭과 높이
    $map_width = 600;
    $map_height = 400;
   
    // 지도의 축적 1~11 사이의 자연수. 1에 가까울 수록 지도가 확대
    $map_zoom = 2;
   
    // 네이버 지도api 키값
    $map_key = "key=코드값";
    if (!$map_query) $map_query = "서울시 강남구 삼성동";
   
    // 여기부터 주소 검색 xml 파싱
    $pquery = $map_key. "&query=". str_replace(" ","",$map_query);  

    $fp = fsockopen ("map.naver.com", 80, $errno, $errstr, 30);
    if (!$fp) {
        echo "$errstr ($errno)";
        //exit;
    } else {
        fputs($fp, "GET /api/geocode.php?");
        fputs($fp, $pquery);
        fputs($fp, " HTTP/1.1\r\n");
        fputs($fp, "Host: map.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 .= $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;
        }
        //header("Content-Type: text/xml; charset=utf-8");
        fclose ($fp);
    }    
    // 여기까지 주소 검색 xml 파싱
 

    // 여기부터 좌표값 변수에 등록
    $map_x_point_1=explode("<x>", $mapbody);
    $map_x_point_2=explode("</x>", $map_x_point_1[1]);
    $map_x_point=$map_x_point_2[0];
    $map_y_point_1=explode("<y>", $mapbody);
    $map_y_point_2=explode("</y>", $map_y_point_1[1]);
    $map_y_point=$map_y_point_2[0];
    // 여기까지 좌표값 변수에 등록
 

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=euckr">
<title>Weddies - 네이버 지도 API 연동</title>
<script type="text/javascript" src="<script type="text/javascript">
function clearText() {
    WedMap.map_query.value = "";
}
</script>
<style>
    .clear {
        clear: both;
    }
    .search {
       
    }
</style>
</head>
<body>
    <h1>TITLE 1</h1>
    <h2>네이버 지도 API 테스트 페이지</h2>
   
    <hr class="clear">
 

    <div id='mapContainer' style='width: <?=$map_width?>px; height: <?=$map_height?>px; padding: 5px; border-style: solid; border-width: 5px; border-color: orange;'>
    <script type="text/javascript">
    <!--
        /*지도 개체 생성 */
     var opts = {width:<?=$map_width?>, height:<?=$map_height?>, mapMode:1};
   
     var mapObj = new NMap(document.getElementById('mapContainer'),opts);
       
        var x_point = <?=$map_x_point?>;
        var y_point = <?=$map_y_point?>;
        var zoom_level = <?=$map_zoom?>;
       
     /* 지도 좌표, 축적 수 준 초기화 */
        var loc_Point = new NPoint(x_point,y_point);  // 포인트 표시
       
     mapObj.setCenterAndZoom(loc_Point,zoom_level);
   
     /* 지도 컨트롤 생성 */
     var zoom = new NZoomControl();
   
     zoom.setAlign("right");
     zoom.setValign("top");
     mapObj.addControl(zoom);
   
     /* 지도 모드 변경 버튼 생성 */
     var mapBtns = new NMapBtns();
     mapBtns.setAlign("right");
     mapBtns.setValign("top");
     mapObj.addControl(mapBtns);
   
    //-->
    </script>
    </div>
   
    <hr class="clear">
   
    <div class="search">
    <form name="WedMap" method="post">
        <input type="text" id="addr" name="map_query" value="검색할 주소를 입력하세요" size="80" maxLength="100" onclick="clearText();" tabindex="1">
        <input type="submit" value="검색">
    </form>
    </div>
   
    <hr class="clear">
   
    <div>
        <ul>
            <dt>주소</dt>
            <dd><?=$map_query?></dd>
            <dt>좌표</dt>
            <dd><?=$map_x_point?></dd>
            <dd><?=$map_y_point?></dd>
        </ul>
    </div>
</body>
</html>

  1. No Image 19Jun
    by
    2020/06/19 Views 619 

    다중 파일을 zip으로 묶어받기

  2. No Image 06Mar
    by
    2017/03/06 Views 19370 

    다중 도메인에 따른 접속방법

  3. No Image 22Sep
    by
    2020/09/22 Views 495 

    네이버 지도 API를 이용한 주소를 좌표로 변환하기 (PHP)

  4. No Image 06Mar
    by
    2017/03/06 Views 18635 

    네이버 지도 API 연동 PHP 소스

  5. No Image 26Mar
    by 조쉬
    2014/03/26 Views 19434 

    네이버 지도 api php버전

  6. No Image 27Mar
    by
    2017/03/27 Views 17940 

    네이버 자동 띄어쓰기를 이용하기

  7. No Image 08Jan
    by
    2019/01/08 Views 1598 

    내 계정 용량 체크

  8. No Image 08Jul
    by
    2021/07/08 Views 752 

    날짜함수 사용하여 한달에 주차 구하기 weeks by month

  9. No Image 24Jul
    by
    2018/07/24 Views 4523 

    날짜계산 몇일까지.. [ ex)4 일전 new 표시 ]

  10. No Image 29Aug
    by
    2018/08/29 Views 2429 

    날짜/시간함수 정리

  11. No Image 04Jul
    by
    2018/07/04 Views 5230 

    날짜, 시간 포맷하기 (PHP)

  12. No Image 07Mar
    by
    2017/03/07 Views 19977 

    날짜 일수 차이 계산

  13. No Image 27Feb
    by
    2014/02/27 Views 21627 

    날짜 계산하기 (하루전 날짜 구하기)

  14. No Image 23Dec
    by
    2016/12/23 Views 20223 

    깨진 한글 체크

  15. No Image 07Mar
    by
    2017/03/07 Views 24849 

    기본적인 페이징

  16. No Image 16Jan
    by
    2019/01/16 Views 1912 

    금액 단위를 만단위부터 표시하는방법

  17. No Image 27Feb
    by
    2014/02/27 Views 29446 

    글내용 이미지 리사이징

  18. No Image 06Mar
    by
    2017/03/06 Views 17606 

    그누보드, 여분필드 사용팁

  19. No Image 12Jan
    by
    2023/01/12 Views 282 

    그누보드 https 보안서버 연결시 오류

  20. No Image 26Mar
    by
    2021/03/26 Views 255 

    구글 학술 검색

Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 ... 17 Next
/ 17

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved