JSFiddle - React, Tailwind, and code Playground

by Manuel Gertrudix

HTML

<!DOCTYPE html>
<html>
  <head>

  </head>
  <body>
    <div id="map"></div>
    
    <script async defer
    src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDmr2x0FWWydp93kDtbO3tgadydoc9bQVc&callback=initMap">
    </script>
  </body>
</html>

CSS

#map {
        height: 100%;
      }

      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }

JavaScript

var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          zoom: 2,
          center: {lat: -33.865427, lng: 151.196123},
          mapTypeId: 'terrain'
        });

        // Creamos, mediante el método createElement, una etiqueta script para pasar el enlace 
        // de la fuente URL con el GeoJSON
        var script = document.createElement('script');

        /* Cargamos un fichero GeoJSON. En este ejemplo, hemos obtenido un fichero del servicio de USGS de terremotos, https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php y lo hemos subido a un servidor propio, ya que no permite hacer llamadas directamente. */
        
        /* - Mediante el atributo src cargamos la URL, selecciondo el head del documento, y añadiendo, 
             con el método appendChild, el script */
                
        script.src = 'http://comunicaciondigital.es/files/masterdatos/earthquakes.geojson';
        document.getElementsByTagName('head')[0].appendChild(script);

        /* - Mediante la clase setStyle se le pasan, a través de una función, los valores de Feature
          de la propiedad mag de cada item del fichero GeoJSON  
           - Con la sentencia return la función devolverá el valor de mag representado con el icono
             círculo */
        map.data.setStyle(function(feature) {
          var magnitude = feature.getProperty('mag');
          return {
            icon: getCircle(magnitude)
          };
        });
      }

      /*  Creamos ahora una función que devuelva como parámetro las opciones del símbolo, en este
           caso: círculo de color rojo, etc. */
      function getCircle(magnitude) {
        return {
          path: google.maps.SymbolPath.CIRCLE,
          fillColor: 'red',
          fillOpacity: .2,
          scale: Math.pow(2, magnitude) / 2,
          strokeColor: 'white',
          strokeWeight: .5
        };
      }
      /* Ahora tenemos que cargar las posiciones de los...