I have data about 250 cities and their population in a GeoJSON file.
{
"type": "FeatureCollection",
"name": "municipial_data",
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features": [ {
"type": "Feature",
"properties": {
"dataset": "population",
"name": "CityName",
"data": {
"stable": {
"y_1994": "15489",
"y_2000": "15524",
"y_2005": "15694",
"y_2010": "15371",
"y_2015": "15095",
"y_2019": "14895"
},
"stable_0_5": {
"y_1994": "731",
"y_2000": "789,
"y_2005": "791",
"y_2010": "701",
"y_2015": "683",
"y_2019": "594"
},
}
}
},
"geometry": {
"type": "MultiPolygon",
"coordinates":
[
[
[
[ 20.0848926, 47.208004], [20.0893161, 47.1978454], .........
]
]
]
} ]
...
I load it to the layer named dataLayer
of a map created with Openlayers v6.6.1. Later in the code I'd like to get the properties, with the dataLayer.getSource().getFeatures()[0].get("name")
method e.g. I can get the name
property of the first city, it works.
Please, help, how can I get the value for the year 1994 (y_1994
) from the stable
property group? I have tried dataLayer.getSource().getFeatures()[0].get("data[stable][y_1994]")
, but only undefined
returns.