Introduction
AMCharts is a powerful JavaScript library widely used for creating interactive charts and maps on the websites. The one of the strongest feature is geo mapping, which allows developers to connect geographic regions with real data and user interactions. In this blog, we will explore how AMCharts can used with custom JSON data to create dynamic, region-based popups that display meaningful information when users interact with a map. This approach helps transform static maps into engaging, data-driven experiences.
Interactive maps change static data into something people actually want to explore. using the AMCharts region-based popups, users can click or hover over a map area and instant see related, localised information pulled from custom data sources. This approach improves engagement, helps users to understand patterns faster, and makes dashboards and analytics tools far more intuitive. AMCharts stands out here because it offers more control over map behaviour, styling, and data handling without unnecessary complexity.
What are AMCharts region-based popups?
Region-based popups are interactive UI elements that appear when a user interacts with a specific geographic area on an AMCharts geo map. Each region, such as a country, state, or city, can display unique content tied directly to that area.
Common use cases include:
- Business analytics dashboards showing regional performance
- Product availability maps
- Geo insights for logistics or operations
- Interactive reports for public or internal users
These pop-ups are based heavily on AMCharts’ custom data mapping to connect geographic regions with meaningful information.
Setting up AMCharts Geo maps (Basic requirements)
Before working with popups, you need a basic geo map in place. This setup ensures your map loads correctly and is ready to connect with custom JSON data later.
Required libraries
Make sure the following AMCharts files are included in your project:
- AMCharts 5 core
- AMCharts 5 maps package
- Relevant geodata files (world, country, or a custom map)
Example using script tags:
<script src="https://cdn.amcharts.com/lib/5/index.js"></script>
<script src="https://cdn.amcharts.com/lib/5/map.js"></script>
<script src="https://cdn.amcharts.com/lib/5/geodata/worldLow.js"></script>
Starter setup
Create a chart root
Create the root element that connects AMCharts to your HTML container.
<div id="chartdiv" style="width: 100%; height: 700px;"></div>
var root = am5.Root.new("chartdiv");
Initialize the map chart
Create the map chart and set basic properties like projection and panning.
var chart = root.container.children.push(
am5map.MapChart.new(root, {
panX: "rotateX",
panY: "rotateY",
projection: am5map.geoMercator()
})
);
Load the desired geodata
Add a polygon series and load the geodata file.
var polygonSeries = chart.series.push(
am5map.MapPolygonSeries.new(root, {
geoJSON: am5geodata_worldLow
})
);
This example is for a world map, but you can replace it with country-specific or custom geodata.AMCharts works with region IDs. These IDs are what you will later match with your JSON data to drive interaction.
This example is for world map, but you can replace it with country-specific or custom geodata.
AMCharts works with region IDs. These IDs are what you will later match with your JSON data to drive interaction.
Preparing custom JSON data for regions
This is where AMCharts JSON data integration becomes important.
Basic JSON structure example
{
"US": {
"title": "United States",
"value": 120,
"description": "High user activity"
},
"CA": {
"title": "Canada",
"value": 80,
"description": "Moderate engagement"
}
}
Best practices
- Use region IDs that match the map’s internal IDs
- Keep naming consistent and predictable
- Store all popup-related content inside each region object
Clear structure makes future updates easier and avoids debugging headaches.
Connecting JSON data to AMCharts map
To link your data with the map:
- Load the JSON file locally or from an API
- Parse the response
- Match JSON keys to map region IDs
- Attach the data to each map polygon
This mapping logic is the backbone of region-based interactivity in AMCharts. If the IDs don’t match, the popups won’t work.
Creating dynamic region-based popups
This is where everything comes together. By using event listeners on map polygons, users can trigger popups on hover or click. When implementation correctly, AMCharts region-based popups can display text, metrics, or also rich HTML content sourced directly from your JSON file.
You can:
- Show popups on hover or click
- Dynamically update content per region
- Style popup layout, fonts, and spacing
- Control positioning and animation behavior
This level of geo map popup customization makes your maps feel polished and intentional.
Advanced enhancements (Optional)
Once the basics work, you can enhance the experience:
- Add subtle animations when popups appear
- Apply conditional colors based on JSON values
- Display charts, icons, or images inside popups
- Highlight regions dynamically based on thresholds
These features work especially well for analytics-heavy dashboards.
Common issues and how to fix them
Region ID mismatch
Ensure JSON keys exactly match map region IDs.
JSON not loading
Check file paths, API responses, and CORS settings.
Popup not appearing
Confirm event listeners are attached correctly.
Formatting issues
Inspect HTML and CSS used inside pop-up content.
Most problems stem from small mismatches or missing bindings.
Final output demo (Optional)
At this stage, you can create fully interactive map where each region responds to user actions with custom data-driven popups. A screenshot or short code snippet can help validate the result for stakeholders or documentation.
Using custom JSON data with AMCharts unlocks scalable and flexible mapping solutions that evolve as your data grows. From internal dashboards to public-facing platforms, this method supports real-world use cases without forcing you into rigid data structures. When implemented thoughtfully, region-based popups in AMCharts become a dependable way to transform geographic data into meaningful, interactive stories.
To get the most impact from such visual experiences, it’s equally important to ensure your designs translate accurately into code. A strong design-to-code workflow helps maintain consistency between visuals and functionality. You can explore this in more detail in our guide on converting Figma designs to pixel-perfect code, which complements data-driven implementations like AMCharts perfectly.