[구글맵] 다중마커 표시

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title> Google Multiple Markers </title>


    <style type="text/css">

      

      #bound {

      height: 60%;

      width: 60%;

      }

      

      

      /* Always set the map height explicitly to define the size of the div

       * element that contains the map. */

       

      

      #map {

        height: 100%;

      }


      /* Optional: Makes the sample page fill the window. */

      html,

      body {

        height: 100%;

        margin: 0;

        padding: 0;

      }

      

      


    </style>

    

    

    <script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>

    <script

      src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap&libraries=&v=weekly"

      defer

    >

    </script>

    

    

  <script>

  

  function initMap() {

      const myLatLng = {

        lat: 37.55902624,

        lng: 126.9749014

      };


    var locations = [

      ['서울역', 37.5546788, 126.9706069],

      ['서울특별시청', 37.5668260, 126.9786567],

      ['을지로입구역', 37.5660373, 126.9821930],

      ['덕수궁', 37.5655638, 126.974894],

    ];


    var map = new google.maps.Map(document.getElementById('map'), {

      zoom: 14,

      center: myLatLng,

    });


    var infowindow = new google.maps.InfoWindow();


    var marker, i;


    for (i = 0; i < locations.length; i++) {  

      marker = new google.maps.Marker({

        position: new google.maps.LatLng(locations[i][1], locations[i][2]),

        map: map

      });


      google.maps.event.addListener(marker, 'click', (function(marker, i) {

        return function() {

          infowindow.setContent(locations[i][0]);

          infowindow.open(map, marker);

        }

      })(marker, i));

    }    

  }

    

    </script>

  </head>

  <body>

  <div id = "bound">

    <div id="map"></div>

  </div>

  </body>

</html>

0
0
이 글을 페이스북으로 퍼가기 이 글을 트위터로 퍼가기 이 글을 카카오스토리로 퍼가기 이 글을 밴드로 퍼가기
captcha
자동등록방지 숫자입력

기타

번호 제목 글쓴이 날짜 조회수
73 [시간] 시간과 관련한 정보가 필요하면 최고관리자 09-18 1,352
72 [Docker compose] Can not find a suitable configuration 에러 원인 최고관리자 09-15 1,384
71 [Docker] CentOS 7 에 Docker를 설치해 보자. 최고관리자 09-14 2,022
70 [소스 컴파일] 컴파일관련 용어를 살펴보자. 최고관리자 09-13 1,500
69 [PHP] 언어 최고관리자 08-18 883
68 [관심] 개발을 오래한 사람이면 공감되는 내용이 많을 것입니다. 최고관리자 08-18 710
67 [VS] code-server를 통해 어디에서든 PC환경으로 개발하자 최고관리자 08-18 687
66 [Mac] Capture Screen Image 폴더 지정 하기 최고관리자 08-02 751
65 [IntelliJ] 여러파일의 이름을 한번에 바꾸는 Plugin 최고관리자 07-29 1,476
64 [모니터] 용도/크기/화질 천차만별! 나한테 맞는 모니터 고르는 법! 최고관리자 07-23 698
63 윈도우 hosts 파일 수정 최고관리자 05-09 873
62 [HTML] image map을 활용한 영역클릭 최고관리자 04-27 796
61 [Linux] CentOS 7에서의 gcc upgrade 최고관리자 08-28 2,635
60 [Linux] wkhtmltopdf error가 해결되지 않을 경우 확인 최고관리자 08-27 1,474
59 [Linux] CentOS7에서 HTML to PDF 실행시 Error 최고관리자 08-27 2,223
58 [Linux] Html to PDF 설치하기 최고관리자 08-27 1,541
57 [Linus] RPM 패키지 관리를 위한 DNF 명령 최고관리자 08-27 1,149
56 [Intellij] 노란줄 Found duplicated code in 해결방법 최고관리자 08-26 1,371
55 [Linux] CentOS sendmail 설치 및 테스트 최고관리자 08-18 2,937
54 [Linux] Console에서 메일보내기 테스트시 EOF(EOT)입력은 어떻게?? 최고관리자 08-18 1,349