<div class="codetitle"> <span><a style="CURSOR: pointer" data="622" class="copybut" id="copybut622" onclick="doCopy('code622')"><u>코드 복사</u></a></span> 코드는 다음과 같습니다.</div> <div class="codebody" id="code622"> <br><script 언어="javascript" type="text /javascript" > <br>//add by ahuinan 2009-8-17 <br>//initialize(23.165613663312594,113.35968017578125) <br>var map; <br>var gdir; <br>var marker2; <br> var hasMarker = false; <br>var hotelLatLng = new GLatLng(<%=initxy %>);//호텔 좌표 초기화 <br>var points = []; points[1] = hotelLatLng; <br>function 초기화() { <br>if (GBrowserIsCompatible()) { <br>map = new GMap2(document.getElementById("divMap"), { googleBarOptions: { showOnLoad: true} }); <br>gdir = new GDirections(map); <br>map.setCenter(hotelLatLng, 9) <br>map.addControl(new GOverviewMapControl()) <br>map.addControl(new GLargeMapControl() ); <br> <br>//검색창 추가<br>map.enableGoogleBar() <br><br>map.enableScrollWheelZoom() <br><br>//드래그할 수 없음 <br>var hotelMarker = new GMarker(new GLatLng(<%=initxy %>)) <br>map.addOverlay(hotelMarker) <br><br>//마우스 왼쪽 버튼으로 마크를 생성할 수 있습니다. <br>GEvent.addListener(map,"click",function(overlay,latlng,overlaylatlng){ <br>if(latlng == null || hasMarker == true){ <br>return; <br>} <br>var greenIcon = 새 GIcon(G_DEFAULT_ICON); <br>greenIcon.image = "../googlemap/green-dot.png"; <br>greenIcon.iconSize = 새 GSize(32,32); iconAnchor = new GPoint(16,32); <br>greenIcon.shadowSize=new GSize(56,33); <br>marker2 = new GMarker(latlng,{draggable: true,icon:greenIcon}); .addOverlay(marker2); <br><br>GEvent.addListener(marker2,"dragend",function(){ <br>points[0] = marker2.getLatLng(); <br>gdir.loadFromWaypoints(points,{ "preserveViewport":true} ); <br><br><br><br>}) <br>GEvent.addListener(gdir, "addoverlay", function(){ <br>for (var i=0; i< ;=gdir.getNumRoutes( ); i ){ <br>var originalMarker = gdir.getMarker(i); <br>map.removeOverlay(originalMarker); <br>} <br>polyline = gdir.getPolyline(); 🎜><br><br>polyline.setStrokeStyle({color:"red",weight:2,opacity:1}) <br>// map.addOverlay(polyline) <br><br>}); <br>hasMarker = true ; <br>points[0] = latlng; <br>gdir.loadFromWaypoints(points,{"preserveViewport":true}) <br>} <br> } <br>// 추가 버튼 누르기<br>function add(){ <br>if(points.length == 1){ <br>alert("라인 없음, 작업 종료") <br>}else { <br>window.opener.document.getElementById("txtHI_MapMarkDesc").value = window.opener.document.getElementById("txtHI_MapMarkDesc").value "n" document.getElementById("txtName").value "||| |" document.getElementById( "txtType").value "||||" 포인트[0] "n"; <br>window.close(); <br>} <br>} <br>window.onload = function() { <br>initialize() <br>} <br></script> <br><br> </div>