본문 바로가기

Javascript

[JavaScript] Node.js Google API 구글 지도 맵 가져오기

반응형

JavaScript node.js 로 Google API 구글 맵 가져오기 

 

구글 맵을 API로 가져오려면 billing 결제 정보를 업데이트하고 confirm을 받아야 온전한 지도, marker 까지 표시할 수 있다. 아직 나의 결제 정보는 confirm 중이여서 먼저 지도만 가져오는 코드만 공유 ! 

 

먼저 Google cloud flatform 에서 API 키를 만들어야 한다.

 

Google API 키 만드는 방법

https://blckchainetc.tistory.com/228

 

[ Google API 최신 ] http://localhost로 구글 로그인 로그아웃 API 사용하기 JavaScript node.js

1. Google Cloud Platform 에 들어간다. https://console.cloud.google.com/apis/dashboard?hl=ko&project=neat-vent-317002&folder=&organizationId= Google Cloud Platform 하나의 계정으로 모든 Google 서비스..

blckchainetc.tistory.com

 

html, javaScript 는 아래와 같다. 

<html>
  <head>
    <title>Simple Map</title>
    <meta name="viewport" content="initial-scale=1.0">
    <meta charset="utf-8">
    <!-- <script src="https://unpkg.com/@googlemaps/markerclustererplus/dist/index.min.js"></script> -->
    <style>
      /* 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>
  </head>


  <body>
    <div id="map"></div>
    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 37.507, lng: 127.144},
          zoom: 13
        });
      }
    </script>
    <script src="https://unpkg.com/@googlemaps/markerclustererplus/dist/index.min.js">
        var markerCluster = new MarkerClusterer(map, markers,
            {imagePath: `${path}/m`});</script>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCIqvyDF1t8f5JlfQ8mh0yDFyiGImaDPyY&callback=initMap"
    async defer></script>
  </body>
</html>

 

반응형