Hi,
I have a problem with this error for a long.
I try to add a layer on the map with some source data, but an error from the title always appear.
Here is the chunk of code which causes the problem:
<Source id="source_id" geoJsonSource={props.places} />
<Layer type="symbol" id="layer_id" sourceId="source_id" />
where:
props.places = {
{
"type":"FeatureCollection",
"features":[
{
"type": "Feature",
"properties": {
"zoomLevelThreshold": "7",
"numberOfAirports": "1",
"sp_score": "",
"value": "Aalborg",
"rank": "10",
"parentId": "DK",
"lat": "57.048",
"lng": "9.9187",
"type": "2",
"id": "aalborg",
"population": "122219"
},
"geometry": {
"type": "Point",
"coordinates": [
9.9187,
57.048
]
}
},
{
"type": "Feature",
"properties": {
"zoomLevelThreshold": "7",
"numberOfAirports": "1",
"sp_score": "",
"value": "Aarhus",
"rank": "10",
"parentId": "DK",
"lat": "56.1898962092",
"lng": "10.3395080566",
"type": "2",
"id": "aarhus",
"population": ""
},
"geometry": {
"type": "Point",
"coordinates": [
10.3395080566,
56.1898962092
]
}
}]
}
}
Solved: Wrong value for type property (FeatureCollection -> geojson) and from property name for features (features -> data)
@StevanCakic Hey, Buddy can you give me a concrete example (code snippet) . Thanks
from https://docs.mapbox.com/mapbox-gl-js/example/multiple-geometries/
source should be something like:
map.addSource('areas', {
type: 'geojson',
data: mapAreas
})
and not
map.addSource('areas', mapAreas)
where mapAreas is the geojson object.
Most helpful comment
Solved: Wrong value for type property (FeatureCollection -> geojson) and from property name for features (features -> data)