React-mapbox-gl: [Question] TypeError: sourceTypes[r.type] is not a constructor

Created on 25 Jul 2017  路  3Comments  路  Source: alex3165/react-mapbox-gl

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
                ]
            }
        }]
       }
}

Most helpful comment

Solved: Wrong value for type property (FeatureCollection -> geojson) and from property name for features (features -> data)

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Beeze picture Beeze  路  15Comments

radeno picture radeno  路  13Comments

suyesh picture suyesh  路  11Comments

evanfrawley picture evanfrawley  路  26Comments

aziz-boudi4 picture aziz-boudi4  路  14Comments