GeoJson type with React Leaflet + Typescript

40 Views Asked by At

i'm running into a type error that I can't manage to fix :

<GeoJSON data={dataGeo} onEachFeature={featureClick} style={(feature: any) => getFeatureStyle(feature.properties.name)} />

the error :

Type '{ type: string; features: ({ type: string; properties: { featurecla: string; scalerank: number; labelrank: number; sovereignt: string; sov_a3: string; adm0_dif: number; level: number; type: string; ... 160 more ...; filename: string; }; geometry: { ...; }; } | ... 7 more ... | { ...; })[]; }' is not assignable to type 'GeoJsonObject'.
  Types of property 'type' are incompatible.
    Type 'string' is not assignable to type '"FeatureCollection" | "Feature" | "Polygon" | "MultiPolygon" | "Point" | "MultiPoint" | "LineString" | "MultiLineString" | "GeometryCollection"'.

My GeoJson structure :

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
       ...
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [...
          ]
        ]
      }
    }

thanks in advance

0

There are 0 best solutions below