What is the expected format of polygon coordinates for RegionMap?

#1

Consider the example polygonConfigs property for a RegionMap component:

"polygonConfigs": [
        {
            "id": "regions",
            "dataSource": "SomeApp.MapRegions",
            "coordinatesField": "regions.geos.geos.geos",
            "coloringScheme": [
                {"field": "name", "comparator": "==", "value": "REGION_A", "color": "#CCE9FF"},
                {"field": "name", "comparator": "==", "value": "REGION_B", "color": "#B2DEFF"}
            ],
            "latField": "lat",
            "longField": "long"
        }
    ]

What format is expected for coordinatesField? Can someone please provide an example of how coordinates are specified for overlays for the RegionMap component?

0 Likes

#2

coordinatesField should be a path for the dataSource to the polygon points that contain latitude and longitude information.

Using your example, that would be a valid config if the SomeApp.MapRegions dataSource returned data that looked like this:

{
  "regions": [
    {
      "geos": {
        "geos": {
          "geos": {
            "lat": "37.513681",
            "long": "-122.201913"
          }
        }
      }
    },
    {
      "geos": {
        "geos": {
          "geos": {
            "lat": "37.422203",
            "long": "-122.165875"
          }
        }
      }
    }
  ]
}

And coordinatesField would be used to map the dataSource data to this list of polygon points:

[
  {
    "lat": "37.513681",
    "long": "-122.201913"
  },
  {
    "lat": "37.422203",
    "long": "-122.165875"
  }
]

And then latField and longField will be used to get the latitude value and longitude value for each item. Note that latField and longField may not be paths—they can only be field names.

1 Like