네이버 지도 오픈 API를 통해서 간단히 만들어서 사이트에 적용시켜 보았습니다.
귀찮아서 간단히 만들어 보았습니다.
php 파일 -------
define(NAVER_MAP_KEY, "네이버오픈API에서 받은 키를 넣어주세요.");
function get_navermap_coods($p_str_addr="")
{
$int_x = 0;
$int_y = 0;
$str_addr = str_replace(" ", "", $p_str_addr);
// curl 이용해서 지도에 필요한 좌표를 취득
$dest_url = "http://openapi.map.naver.com/api/geocode.php?key=" . NAVER_MAP_KEY . "&encoding=utf-8&coord=LatLng&query=" . urlencode($str_addr);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $dest_url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$str_result = curl_exec($ch);
curl_close($ch);
$obj_xml = simplexml_load_string($str_result);
$int_x = $obj_xml->item->point->x;
$int_y = $obj_xml->item->point->y;
return array($int_x, $int_y);
}
// 주소에서 좌표를 추출한다.
$str_addr = "서울시 강동구 길동 96-4";
list($int_x, $int_y) = get_navermap_coods($str_addr);
html 파일 --------------------------
<!-- 네이버 지도 스크립트는 상단에 위치하면 된다.-->
<script type="text/javascript">
try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}
</script>
<script type="text/javascript" src="http://openapi.map.naver.com/openapi/naverMap.naver?ver=2.0&key=<?= NAVER_MAP_KEY; ?>"></script>
<!-- 네이버 지도는 필요한 곳에 붙여넣으면 됩니다. -->
<div id = "naverMap" style="border:1px solid #000; width:431px; height:288px; margin:20px;"></div>
<script type="text/javascript">
var oPoint = new nhn.api.map.LatLng(<?= $int_y; ?>, <?= $int_x; ?>); // - 지도의 중심점을 나타내는 변수 선언
nhn.api.map.setDefaultPoint('LatLng'); // - 지도에서 기본적으로 사용하는 좌표계를 설정합니다.
var markerCount = 0;
oMap = new nhn.api.map.Map('naverMap', {
point : oPoint,
zoom : 10, // - 초기 줌 레벨은 10으로 둔다.
enableWheelZoom : false,
enableDragPan : true,
enableDblClickZoom : false,
mapMode : 0,
activateTrafficMap : false,
activateBicycleMap : false,
minMaxLevel : [ 1, 14 ],
size : new nhn.api.map.Size(431, 288)
});
var mapZoom = new nhn.api.map.ZoomControl(); // - 줌 컨트롤 선언
themeMapButton = new nhn.api.map.ThemeMapBtn(); // - 자전거지도 버튼 선언
mapTypeChangeButton = new nhn.api.map.MapTypeBtn(); // - 지도 타입 버튼 선언
var trafficButton = new nhn.api.map.TrafficMapBtn(); // - 실시간 교통지도 버튼 선언
trafficButton.setPosition({top:10, right:110}); // - 실시간 교통지도 버튼 위치 지정
mapTypeChangeButton.setPosition({top:10, left:50}); // - 지도 타입 버튼 위치 지정
themeMapButton.setPosition({top:10, right:10}); // - 자전거지도 버튼 위치 지정
mapZoom.setPosition({left:10, top:10}); // - 줌 컨트롤 위치 지정.
oMap.addControl(mapZoom);
oMap.addControl(themeMapButton);
oMap.addControl(mapTypeChangeButton);
oMap.addControl(trafficButton);
var oSize = new nhn.api.map.Size(28, 37);
var oOffset = new nhn.api.map.Size(14, 37);
var oIcon = new nhn.api.map.Icon('http://static.naver.com/maps2/icons/pin_spot2.png', oSize, oOffset);
var oMarker = new nhn.api.map.Marker(oIcon, { title : '<?= $str_hospital_name; ?>' }); //마커 생성
oMarker.setPoint(oPoint);
oMap.addOverlay(oMarker);
var oLabel = new nhn.api.map.MarkerLabel(); // - 마커 라벨 선언.
oMap.addOverlay(oLabel); // - 마커 라벨 지도에 추가. 기본은 라벨이 보이지 않는 상태로 추가됨.
oLabel.setVisible(true, oMarker); // 마커 라벨 보이기
</script>
<!-- 네이버 지도 끝 -->
귀찮아서 간단히 만들어 보았습니다.
php 파일 -------
define(NAVER_MAP_KEY, "네이버오픈API에서 받은 키를 넣어주세요.");
function get_navermap_coods($p_str_addr="")
{
$int_x = 0;
$int_y = 0;
$str_addr = str_replace(" ", "", $p_str_addr);
// curl 이용해서 지도에 필요한 좌표를 취득
$dest_url = "http://openapi.map.naver.com/api/geocode.php?key=" . NAVER_MAP_KEY . "&encoding=utf-8&coord=LatLng&query=" . urlencode($str_addr);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $dest_url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$str_result = curl_exec($ch);
curl_close($ch);
$obj_xml = simplexml_load_string($str_result);
$int_x = $obj_xml->item->point->x;
$int_y = $obj_xml->item->point->y;
return array($int_x, $int_y);
}
// 주소에서 좌표를 추출한다.
$str_addr = "서울시 강동구 길동 96-4";
list($int_x, $int_y) = get_navermap_coods($str_addr);
html 파일 --------------------------
<!-- 네이버 지도 스크립트는 상단에 위치하면 된다.-->
<script type="text/javascript">
try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}
</script>
<script type="text/javascript" src="http://openapi.map.naver.com/openapi/naverMap.naver?ver=2.0&key=<?= NAVER_MAP_KEY; ?>"></script>
<!-- 네이버 지도는 필요한 곳에 붙여넣으면 됩니다. -->
<div id = "naverMap" style="border:1px solid #000; width:431px; height:288px; margin:20px;"></div>
<script type="text/javascript">
var oPoint = new nhn.api.map.LatLng(<?= $int_y; ?>, <?= $int_x; ?>); // - 지도의 중심점을 나타내는 변수 선언
nhn.api.map.setDefaultPoint('LatLng'); // - 지도에서 기본적으로 사용하는 좌표계를 설정합니다.
var markerCount = 0;
oMap = new nhn.api.map.Map('naverMap', {
point : oPoint,
zoom : 10, // - 초기 줌 레벨은 10으로 둔다.
enableWheelZoom : false,
enableDragPan : true,
enableDblClickZoom : false,
mapMode : 0,
activateTrafficMap : false,
activateBicycleMap : false,
minMaxLevel : [ 1, 14 ],
size : new nhn.api.map.Size(431, 288)
});
var mapZoom = new nhn.api.map.ZoomControl(); // - 줌 컨트롤 선언
themeMapButton = new nhn.api.map.ThemeMapBtn(); // - 자전거지도 버튼 선언
mapTypeChangeButton = new nhn.api.map.MapTypeBtn(); // - 지도 타입 버튼 선언
var trafficButton = new nhn.api.map.TrafficMapBtn(); // - 실시간 교통지도 버튼 선언
trafficButton.setPosition({top:10, right:110}); // - 실시간 교통지도 버튼 위치 지정
mapTypeChangeButton.setPosition({top:10, left:50}); // - 지도 타입 버튼 위치 지정
themeMapButton.setPosition({top:10, right:10}); // - 자전거지도 버튼 위치 지정
mapZoom.setPosition({left:10, top:10}); // - 줌 컨트롤 위치 지정.
oMap.addControl(mapZoom);
oMap.addControl(themeMapButton);
oMap.addControl(mapTypeChangeButton);
oMap.addControl(trafficButton);
var oSize = new nhn.api.map.Size(28, 37);
var oOffset = new nhn.api.map.Size(14, 37);
var oIcon = new nhn.api.map.Icon('http://static.naver.com/maps2/icons/pin_spot2.png', oSize, oOffset);
var oMarker = new nhn.api.map.Marker(oIcon, { title : '<?= $str_hospital_name; ?>' }); //마커 생성
oMarker.setPoint(oPoint);
oMap.addOverlay(oMarker);
var oLabel = new nhn.api.map.MarkerLabel(); // - 마커 라벨 선언.
oMap.addOverlay(oLabel); // - 마커 라벨 지도에 추가. 기본은 라벨이 보이지 않는 상태로 추가됨.
oLabel.setVisible(true, oMarker); // 마커 라벨 보이기
</script>
<!-- 네이버 지도 끝 -->
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7030 | 11년 전 | 1427 | ||
| 7029 |
|
11년 전 | 3251 | |
| 7028 |
|
11년 전 | 1155 | |
| 7027 | 11년 전 | 1015 | ||
| 7026 | 11년 전 | 2095 | ||
| 7025 |
어려워요잉
|
11년 전 | 2749 | |
| 7024 | 11년 전 | 2109 | ||
| 7023 | 11년 전 | 3144 | ||
| 7022 |
Shhhh
|
11년 전 | 1545 | |
| 7021 |
|
11년 전 | 3286 | |
| 7020 | 11년 전 | 797 | ||
| 7019 |
막돼먹은영애
|
11년 전 | 1088 | |
| 7018 | 11년 전 | 1966 | ||
| 7017 | 11년 전 | 2329 | ||
| 7016 | 11년 전 | 1034 | ||
| 7015 | 11년 전 | 2840 | ||
| 7014 | 11년 전 | 3033 | ||
| 7013 | 11년 전 | 1520 | ||
| 7012 |
|
11년 전 | 2203 | |
| 7011 | 11년 전 | 1050 | ||
| 7010 | 11년 전 | 1408 | ||
| 7009 |
|
11년 전 | 1088 | |
| 7008 | 11년 전 | 2274 | ||
| 7007 | 11년 전 | 2193 | ||
| 7006 |
|
11년 전 | 1183 | |
| 7005 | 11년 전 | 5315 | ||
| 7004 | 11년 전 | 2366 | ||
| 7003 | 11년 전 | 3081 | ||
| 7002 | 11년 전 | 1931 | ||
| 7001 | 11년 전 | 986 | ||
| 7000 | 11년 전 | 2055 | ||
| 6999 |
|
11년 전 | 2176 | |
| 6998 | 11년 전 | 1891 | ||
| 6997 |
네이비칼라
|
11년 전 | 1502 | |
| 6996 | 11년 전 | 963 | ||
| 6995 |
|
11년 전 | 1870 | |
| 6994 | 11년 전 | 2585 | ||
| 6993 |
kimsdesign
|
11년 전 | 1309 | |
| 6992 |
|
11년 전 | 2781 | |
| 6991 | 11년 전 | 1725 | ||
| 6990 | 11년 전 | 4481 | ||
| 6989 | 11년 전 | 1867 | ||
| 6988 |
네이비컬러
|
11년 전 | 2529 | |
| 6987 | 11년 전 | 3737 | ||
| 6986 |
잘살아보자
|
11년 전 | 1601 | |
| 6985 |
잘살아보자
|
11년 전 | 2485 | |
| 6984 | 11년 전 | 831 | ||
| 6983 |
천재조상훈
|
11년 전 | 1880 | |
| 6982 |
천재조상훈
|
11년 전 | 4514 | |
| 6981 |
천재조상훈
|
11년 전 | 1644 | |
| 6980 |
|
11년 전 | 1893 | |
| 6979 |
|
11년 전 | 768 | |
| 6978 |
잘살아보자
|
11년 전 | 1157 | |
| 6977 |
잘살아보자
|
11년 전 | 1476 | |
| 6976 |
잘살아보자
|
11년 전 | 1586 | |
| 6975 |
천재조상훈
|
11년 전 | 1495 | |
| 6974 |
잘살아보자
|
11년 전 | 2238 | |
| 6973 |
잘살아보자
|
11년 전 | 1166 | |
| 6972 |
잘살아보자
|
11년 전 | 3075 | |
| 6971 |
잘살아보자
|
11년 전 | 3281 | |
| 6970 |
잘살아보자
|
11년 전 | 1853 | |
| 6969 |
잘살아보자
|
11년 전 | 4787 | |
| 6968 | 11년 전 | 9914 | ||
| 6967 |
|
11년 전 | 2645 | |
| 6966 |
|
11년 전 | 1119 | |
| 6965 | 11년 전 | 3267 | ||
| 6964 | 11년 전 | 2590 | ||
| 6963 | 11년 전 | 2108 | ||
| 6962 |
star3840
|
11년 전 | 1022 | |
| 6961 | 11년 전 | 4251 | ||
| 6960 |
|
11년 전 | 740 | |
| 6959 | 11년 전 | 1267 | ||
| 6958 |
|
11년 전 | 1682 | |
| 6957 | 11년 전 | 1910 | ||
| 6956 |
잘살아보자
|
11년 전 | 1858 | |
| 6955 | 11년 전 | 4634 | ||
| 6954 | 11년 전 | 1637 | ||
| 6953 |
잘살아보자
|
11년 전 | 885 | |
| 6952 |
잘살아보자
|
11년 전 | 2056 | |
| 6951 | 11년 전 | 1618 | ||
| 6950 | 11년 전 | 2620 | ||
| 6949 |
잘살아보자
|
11년 전 | 897 | |
| 6948 | 11년 전 | 1564 | ||
| 6947 | 11년 전 | 1475 | ||
| 6946 | 11년 전 | 1622 | ||
| 6945 | 11년 전 | 1232 | ||
| 6944 | 11년 전 | 1194 | ||
| 6943 | 11년 전 | 1238 | ||
| 6942 | 11년 전 | 1592 | ||
| 6941 | 11년 전 | 1666 | ||
| 6940 | 11년 전 | 1761 | ||
| 6939 | 11년 전 | 1672 | ||
| 6938 | 11년 전 | 1952 | ||
| 6937 | 11년 전 | 1163 | ||
| 6936 | 11년 전 | 1365 | ||
| 6935 | 11년 전 | 1308 | ||
| 6934 | 11년 전 | 1475 | ||
| 6933 | 11년 전 | 1987 | ||
| 6932 | 11년 전 | 1547 | ||
| 6931 | 11년 전 | 1549 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기