Background Vector
US
Background Vector

πŸ“ Installation Guide - GEO Map Hub Plugin

Now it's time to bring your ideas to life! Follow the implementation guide to integrate GEO Map Hub seamlessly into your application. Customize your maps with region coloring, markers, tooltips, click actions, and many more features. In just a few simple steps, you'll unlock the full potential of interactive mapping for your users.

πŸ“ Folder Structure

Before you begin, make sure your project files are organized like this:

your-project/
β”œβ”€β”€ gmh-plugin/
β”‚   β”œβ”€β”€ assets/
β”‚   β”‚   β”œβ”€β”€ css/
β”‚   β”‚   β”‚   └── style.css
β”‚   β”‚   β”œβ”€β”€ js/
β”‚   β”‚   β”‚    β”œβ”€β”€ script/
β”‚   β”‚   β”‚    β”‚    β”œβ”€β”€ geomaphub.js
β”‚   β”‚   β”‚    β”‚    β”œβ”€β”€ lib/
β”‚   β”‚   β”‚    β”‚    β”‚    β”œβ”€β”€ interactive-tooltip-gmh.js   ← Required for tooltip
β”‚   β”‚   β”‚    β”‚    β”‚    β”œβ”€β”€ colored-marker-gmh.js
β”‚   β”‚   β”‚    β”‚    β”‚    β”œβ”€β”€ simple-zoom-gmh.js
β”‚   β”‚   β”‚    β”‚    β”‚    └── ...
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ us/
β”‚   β”‚   β”‚   β”œβ”€β”€ map-content.js
β”‚   β”‚   β”‚   β”œβ”€β”€ map-content-drilldown.js
β”‚   β”‚   β”‚   β”œβ”€β”€ us.svg
β”‚   β”‚   β”‚   └── us-drill-down.svg
β”‚   β”‚   β”œβ”€β”€ de/
β”‚   β”‚   β”‚   └── ...
β”œβ”€β”€ index.html (e.g. Display Feature Advanced Zoom, Color Marker..)

πŸ“Œ Use blank-map-content.js in production (instead of demo versions) for clean and scalable data config.

🧱 Step-by-Step Setup

1. Include the CSS

Inside your <head> tag:

<link rel="stylesheet" href="/gmh-plugin/assets/css/style.css">

This CSS makes the SVG map responsive and styled correctly.

2. Add Tooltip elements

Add these two elements after body tag.

<div id="tooltip-gmh"></div>
<div id="custom-tooltip-gmh"></div>

3. Add the Map Container

Wherever you want to render the map in your HTML:

<div class="svg-container-gmh">
  <div id="svg-wrapper-gmh"></div>
</div>

This is the element where the map will load.

4. Load and Initialize the Map (Using ES Modules)

Paste this at the end of the <body> tag:

<script type="module">
   const currentCountry = "us"; // Change this to your target country code

   async function initMap() {
      try {
         const {map_config, general_config} = await import(`/gmh-plugin/data/${currentCountry}/map-content.js`);
         const {GEOMapHub} = await import('/gmh-plugin/assets/js/script/geomaphub.js');
         const {geoMapHubColoredMarker} = await import('/gmh-plugin/assets/js/script/lib/colored-marker-gmh.js');
         const {geoMapHubSimpleZoom} = await import('/gmh-plugin/assets/js/script/lib/simple-zoom-gmh.js');
         const {geoMapHubInteractiveTooltip} = await import('/gmh-plugin/assets/js/script/lib/interactive-tooltip-gmh.js');

         const map = new GEOMapHub("#svg-wrapper-gmh", {
            svgUrl: `/gmh-plugin/data/${currentCountry}/${currentCountry}.svg`,
            mapConfig: map_config,
            generalConfig: general_config,
         });

         // Register only the plugins you need
         map.registerPlugin(geoMapHubColoredMarker);
         map.registerPlugin(geoMapHubSimpleZoom);
         map.registerPlugin(geoMapHubInteractiveTooltip);

         map.init();
      } catch (error) {
         console.error("Error initializing map:", error);
      }
   }

   initMap();
</script>
🚫 CORS Error – Avoid file:/// Access

If you open your .html file directly from the file system, like this:

file:///D:/your-project/index.html

You'll see an error like:

Access to script at 'file:///D:/data/us/map-content-drill-down.js' from origin 'null' has been blocked by CORS policy:
Cross origin requests are only supported for protocol schemes: chrome, chrome-extension, chrome-untrusted, data, http, https, isolated-app.
❓ Why?
  • JavaScript ES Modules must be loaded over http:// or https:// protocols.

  • file:// is not a secure context, so browsers block dynamic imports from it.

βœ… How to Fix

Option 1: Use a Local Server (Recommended for HTML)

  • Live Server (VS Code Extension)

    Install Live Server, right-click your HTML, and choose β€œOpen with Live Server”.

  • use any other local server:

    # Python 3
    python -m http.server
    
    # Node.js
    npx http-server
    
    # PHP
    php -S localhost:8080
    
  • Or use a local web server (e.g., XAMPP or Laragon)

Option 2: Deploy to a Real Server

You can upload your files to:

  • Your cPanel or shared hosting

  • A staging VPS or domain

Once the files are accessible via http:// or https://, the plugin works without issues.

Example Integration for Feature:

To display a feature (e.g. Advanced Zoom, Color Marker ...), your file should look like this:

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>GEO Map Hub Plugin | Installation</title>
   <link rel="stylesheet" href="/gmh-plugin/assets/css/style.css" />
</head>
<body>
  <div class="container">
    <div class="row">
      <div class="col-12">
        <h2>Colored Marker</h2>
      </div>
    </div>

    <div class="row row-gap-2">
      <div class="col-lg-12 col-12">
        <div class="svg-container-gmh">
          <div id="html-content-gmh"></div>
          <div class="mt-2" id="svg-wrapper-gmh"></div>
        </div>
      </div>
    </div>
  </div>

  <!-- Color Marker -->
  <script type="module">
    const currentCountry = "us"; // Change this to your target country code

    async function initMap() {
      try {
        // Dynamically import map-specific data
        const {map_config, general_config} = await import(`/gmh-plugin/data/${currentCountry}/map-content.js`);
        const {GEOMapHub} = await import('/gmh-plugin/assets/js/script/geomaphub.js');
        const {geoMapHubColoredMarker} = await import('/gmh-plugin/assets/js/script/lib/colored-marker-gmh.js');
        const {geoMapHubSimpleZoom} = await import('/gmh-plugin/assets/js/script/lib/simple-zoom-gmh.js');
        const {geoMapHubInteractiveTooltip} = await import('/gmh-plugin/assets/js/script/lib/interactive-tooltip-gmh.js');

        const map = new GEOMapHub("#svg-wrapper-gmh", {
          svgUrl: `/gmh-plugin/data/${currentCountry}/${currentCountry}.svg`,
          mapConfig: map_config,
          generalConfig: general_config,
        });

        map.registerPlugin(geoMapHubColoredMarker);
        map.registerPlugin(geoMapHubSimpleZoom);
        map.registerPlugin(geoMapHubInteractiveTooltip);

        map.init();
      } catch (error) {
        console.error("Error initializing map:", error);
      }
    }

    initMap();
  </script>
  <!-- Color Marker -->
</body>
</html>
βœ… Testing Checklist
βœ… Checkpoint Description
βœ”οΈ SVG loads on page Map should be visible without zoom/plugins
βœ”οΈ Tooltip appears on hover Provided interactive-tooltip-gmh.js is loaded
βœ”οΈ Zoom/pan functionality Confirm plugin is registered
βœ”οΈ No console errors Especially for 404, CORS, or null origin
βœ”οΈ Works on different country Switch country code to de, jp, etc. and test
🧩 Final Notes
  • Only include plugins you need – don't register unused ones.

  • Use blank-map-content.js for production instead of the demo file.

  • Tooltip plugin (interactive-tooltip-gmh.js) is essential for region interactivity - do not skip it if you need hover labels or clickable tooltips.