Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- Google includes -->
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDwgeYC36l4W8BZlV2kOqGl671dYXGRK_Q&callback=initGoogleMap" defer></script>

<!-- amCharts includes -->
<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/maps.js"></script>
<script src="https://www.amcharts.com/lib/4/geodata/worldLow.js"></script>

<!-- HTML -->
<div id="maps">
  <div id="gmap" class="mapdiv" style="visibility: visible;"></div>
  <div id="ammap" class="mapdiv" style="visibility: visible;"></div>
</div>
              
            
!

CSS

              
                #maps {
  width: 510px;
  height: 500px;
  border: 0px solid #eee;
  margin: 0px auto;
  position: relative;
}

.mapdiv {
  width: 510px;
  height: 500px;
  position: absolute;
  top: 0;
  left: 0;
}
              
            
!

JS

              
                /**
 * ---------------------------------------
 * This demo was created using amCharts 4.
 *
 * For more information visit:
 * https://www.amcharts.com/
 *
 * Documentation is available at:
 * https://www.amcharts.com/docs/v4/
 * ---------------------------------------
 */

/**
 * Create the Google Map
 */
var gmap;

function initGoogleMap() {
  gmap = new google.maps.Map(document.getElementById("gmap"), {
    scrollwheel: true,
    disableDefaultUI: true
  });
}

/**
 * Create the amCharts Map
 */

// Create map instance
var ammap = am4core.create("ammap", am4maps.MapChart);
ammap.geodata = am4geodata_worldLow;
ammap.projection = new am4maps.projections.Mercator();
ammap.zoomDuration = 0;

var polygonSeries = ammap.series.push(new am4maps.MapPolygonSeries());
polygonSeries.exclude = ["AQ"];
polygonSeries.useGeodata = true;

// Add zoom control
ammap.zoomControl = new am4maps.ZoomControl();

// Configure series
var polygonTemplate = polygonSeries.mapPolygons.template;
polygonTemplate.tooltipText = "{name}";
polygonTemplate.fill = am4core.color("#74B266");
polygonTemplate.fillOpacity = 0.5;

var hs = polygonTemplate.states.create("hover");
hs.properties.fill = am4core.color("#367B25");

// Set up GMap centering
ammap.events.on("zoomlevelchanged", updateMapPosition);
ammap.events.on("mappositionchanged", updateMapPosition);
ammap.events.on("scaleratiochanged", updateMapPosition);

function updateMapPosition(ev) {
  /**
   * GMap inited?
   */
  if ( typeof gmap === "undefined" )
    return;

  // set google map zoom level:
  gmap.setZoom(Math.log2(ammap.zoomLevel) + 1);

  // sync position
  gmap.setCenter( {
    // a small adjustment needed for this div size:
    lat: ammap.zoomGeoPoint.latitude,
    lng: ammap.zoomGeoPoint.longitude
  } );
}
              
            
!
999px

Console