<div id="map"></div>
// load the map SVG file from a URL
  // get the raw text content of SVG file as a string
  .then(response => response.text())
  .then((image) => {
    // This is a workaround for a strange behavior (a bug?)
    // of svg.js library
    let startOfSvg = image.indexOf('<svg')
    startOfSvg = startOfSvg >= 0 ? startOfSvg : 0

    // Draw the map
    const draw = SVG(image.slice(startOfSvg))
      .size('100%', '500')
      // Add zoom and pan capabilities with mouse wheel and mouse dragging
    // loop over all regions
    for (const region of draw.find('path')) {
      // paint each region blue
      // add a label to the center of each region
          size: '1.25em',
          family: 'sans-serif'
        .center(region.cx(), region.cy())

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://unpkg.com/@svgdotjs/svg.js@3.0.16/dist/svg.min.js
  2. https://unpkg.com/@svgdotjs/svg.panzoom.js@2.1.1/dist/svg.panzoom.min.js