I am relatively new to ammCharts and it is my first attempt to create a geoJSON file also.
The following is my geoJson file:
GeoJSON file
This is what I am trying to achieve: example
When I load my geoJson this is what happens :
So only one polygon is actively working. For some reason I am having problems and could not make jsfiddle or codepen of the code. I believe something is wrong in my geoJSON as I have loaded other random Geojson Files they work fine with the codepen created by amcharts just mine dosent work.
I am using geojson.io to create the geoJson.
GeoJSON is an open standard geospatial data interchange format that represents simple geographic features and their nonspatial attributes. Based on JavaScript Object Notation (JSON), GeoJSON is a format for encoding a variety of geographic data structures.
Make Your GeoJSON Interactive With FME your 2D data can become 3D! By converting GeoJSON data to Cesium 3D Tiles you'll be able to drag, scale, and rotate your data in Cesium's dynamic display. You can even see the stars come out of the sky using the timeline widget.
You can open GeoJSON files from your computer, Google Drive. GeoJSON Map Viewer is a tool that views the GeoJSON file in your browser. This app allows you to validate your GeoJSON and display it on a Google map.
If you have a geojson file on your local hard drive or network and want to view/use it in QGIS, you can just drag and drop it from the Browser Panel into the Layers Panel or just double click on the file will add it to the Layers Panel.
The issue with your geoJSON is that it lacks ids. AmCharts' maps require unique IDs for each region. Since there's no "id"
property set in any of your regions, they'll all default to null, allowing only one of the regions to be highlighted. I modified your JSON and added ids with the same value as the district in each region like so:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"division": "Muzaffarabad",
"district": "Muzaffarabad",
"id": "Muzaffarabad",
// ... others omitted
I also modified the example to add a "title"
attribute to the converted object so that you'll get the name of the area when you hover over it by default:
for(var i = 0; i < svg.length; i++) {
var path = svg[i];
var attrs = path.match(/\w+=".*?"/g);
var area = {};
for(var x = 0; x < attrs.length; x++) {
var parts = attrs[x].replace(/"/g, '').split("=");
var key = fieldMap[parts[0]] || parts[0];
area[key] = parts[1];
}
//added for hover-over balloons
area["title"] = area["id"];
mapVar.svg.g.path.push(area);
}
Here's a demo with the modified file and example code. You can find the fully modified geoJSON file here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With