IT

html 사이트에 google map 추가하기

Prod. No. 7 2014. 11. 3. 12:13

Head 부분에 아래 script 추가

여기서 좌표는 google map 들어가서 검색 후에 이곳이 궁금한가요? 선택하면 좌표 나옴.


<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> 

 <script> 

  function initialize() { 

  var myLatlng = new google.maps.LatLng(35.559815, 123.972293); 

  var buildingLoc = new google.maps.LatLng(35.559815, 123.972293);

  var mapOptions = { 

        zoom: 17, 

        center: myLatlng, 

        mapTypeId: google.maps.MapTypeId.ROADMAP 

  } 

  var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); 

  var marker = new google.maps.Marker({

position: buildingLoc,

map: map,

title: "테스트위치"

});

  }

</script>


body tag 에 <body onload="initialize()"> 추가해주고...

삽일할 부분에 아래 소스 추가하면 끝~! (가로 세로는 크기임)


<div id="map_canvas"style="width:1000px; height:300px;"></div>