Attempting to generate a
<Map
{...}
<GeoJSON
data={...} <- Here I insert my feature in JSON format
style={...} <- Relevant style settings
/>
/>
However, when trying the exact same approach in Typescript, I face the following error:
No overload matches this call.
Overload 1 of 2, '(props: Readonly<GeoJSONProps>): GeoJSON<GeoJSONProps, GeoJSON<any>>', provided the following error.
Type '{ type: string; geometry: { type: string; coordinates: number[]; }; }' cannot be assigned to type 'GeoJsonObject'.
Object literal can only specify known properties, and 'geometry' does not exist in type 'GeoJsonObject'.
Overload 2 of 2, '(props: GeoJSONProps, context?: any): GeoJSON<GeoJSONProps, GeoJSON<any>>', provided the following error.
Type '{ type: string; geometry: { type: string; coordinates: number[]; }; }' cannot be assigned to type 'GeoJsonObject'.
Object literal can only specify known properties, and 'geometry' does not exist in type 'GeoJsonObject'.ts(2769)
I have attempted many variations, one of which looks like this:
<Map
{...}
<GeoJSON
data={{
type: "Feature",
geometry: {
type: "Point",
coordinates: [125.6, 10.1]
}
}}
/>
/>
Upon inspecting the type definition of GeoJsonObject, it lacks the "geometry" field, only having the "type" field. How should I pass the geometry to the GeoJSON element I am creating? (type definition of GeoJsonObject: )
This code works in standard javascript, do you know why?