네이버 지도 오픈 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>
<!-- 네이버 지도 끝 -->
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6130 |
gender
|
12년 전 | 1089 | |
| 6129 | 12년 전 | 1321 | ||
| 6128 |
|
12년 전 | 3461 | |
| 6127 | 12년 전 | 695 | ||
| 6126 |
|
12년 전 | 2206 | |
| 6125 |
|
12년 전 | 4884 | |
| 6124 | 12년 전 | 660 | ||
| 6123 | 12년 전 | 3838 | ||
| 6122 | 12년 전 | 1016 | ||
| 6121 | 12년 전 | 3749 | ||
| 6120 | 12년 전 | 907 | ||
| 6119 | 12년 전 | 1769 | ||
| 6118 | 12년 전 | 928 | ||
| 6117 | 12년 전 | 2147 | ||
| 6116 | 12년 전 | 7942 | ||
| 6115 | 12년 전 | 1918 | ||
| 6114 |
|
12년 전 | 1705 | |
| 6113 | 12년 전 | 1522 | ||
| 6112 | 12년 전 | 592 | ||
| 6111 | 12년 전 | 2109 | ||
| 6110 | 12년 전 | 1849 | ||
| 6109 | 12년 전 | 638 | ||
| 6108 | 12년 전 | 1197 | ||
| 6107 | 12년 전 | 618 | ||
| 6106 | 12년 전 | 903 | ||
| 6105 | 12년 전 | 1189 | ||
| 6104 | 12년 전 | 3593 | ||
| 6103 | 12년 전 | 2120 | ||
| 6102 | 12년 전 | 2311 | ||
| 6101 | 12년 전 | 3674 | ||
| 6100 | 12년 전 | 3481 | ||
| 6099 | 12년 전 | 3149 | ||
| 6098 | 12년 전 | 4022 | ||
| 6097 | 12년 전 | 1012 | ||
| 6096 | 12년 전 | 5978 | ||
| 6095 | 12년 전 | 1369 | ||
| 6094 | 12년 전 | 1223 | ||
| 6093 | 12년 전 | 3404 | ||
| 6092 | 12년 전 | 3051 | ||
| 6091 | 12년 전 | 5192 | ||
| 6090 | 12년 전 | 2701 | ||
| 6089 | 12년 전 | 3326 | ||
| 6088 | 12년 전 | 1014 | ||
| 6087 | 12년 전 | 846 | ||
| 6086 | 12년 전 | 2017 | ||
| 6085 |
|
12년 전 | 806 | |
| 6084 |
웹디자인되고파
|
12년 전 | 2216 | |
| 6083 | 12년 전 | 1506 | ||
| 6082 | 12년 전 | 1109 | ||
| 6081 | 12년 전 | 2097 | ||
| 6080 |
Stiven
|
12년 전 | 2312 | |
| 6079 |
프로프리랜서
|
12년 전 | 1317 | |
| 6078 |
프로프리랜서
|
12년 전 | 786 | |
| 6077 |
프로프리랜서
|
12년 전 | 1341 | |
| 6076 |
프로프리랜서
|
12년 전 | 829 | |
| 6075 |
프로프리랜서
|
12년 전 | 1219 | |
| 6074 | 12년 전 | 3854 | ||
| 6073 | 12년 전 | 3949 | ||
| 6072 | 12년 전 | 1373 | ||
| 6071 | 12년 전 | 6990 | ||
| 6070 | 12년 전 | 7574 | ||
| 6069 | 12년 전 | 2318 | ||
| 6068 | 12년 전 | 3866 | ||
| 6067 |
smwkd
|
12년 전 | 632 | |
| 6066 | 12년 전 | 3655 | ||
| 6065 | 12년 전 | 3486 | ||
| 6064 | 12년 전 | 2720 | ||
| 6063 | 12년 전 | 2840 | ||
| 6062 | 12년 전 | 2368 | ||
| 6061 | 12년 전 | 2276 | ||
| 6060 | 12년 전 | 5182 | ||
| 6059 | 12년 전 | 2811 | ||
| 6058 | 12년 전 | 3133 | ||
| 6057 | 12년 전 | 2261 | ||
| 6056 | 12년 전 | 6839 | ||
| 6055 | 12년 전 | 2581 | ||
| 6054 | 12년 전 | 3433 | ||
| 6053 | 12년 전 | 2323 | ||
| 6052 | 12년 전 | 4817 | ||
| 6051 | 12년 전 | 3710 | ||
| 6050 | 12년 전 | 2553 | ||
| 6049 | 12년 전 | 2243 | ||
| 6048 |
|
12년 전 | 1294 | |
| 6047 | 12년 전 | 3437 | ||
| 6046 | 12년 전 | 4094 | ||
| 6045 | 12년 전 | 3454 | ||
| 6044 | 12년 전 | 5331 | ||
| 6043 | 12년 전 | 1650 | ||
| 6042 | 12년 전 | 1281 | ||
| 6041 | 12년 전 | 5163 | ||
| 6040 | 12년 전 | 937 | ||
| 6039 | 12년 전 | 3408 | ||
| 6038 | 12년 전 | 3410 | ||
| 6037 | 12년 전 | 2992 | ||
| 6036 | 12년 전 | 3340 | ||
| 6035 | 12년 전 | 2867 | ||
| 6034 | 12년 전 | 2844 | ||
| 6033 | 12년 전 | 2866 | ||
| 6032 | 12년 전 | 2854 | ||
| 6031 | 12년 전 | 2878 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기