我正在尝试从 Typescript 中的功能创建 <GeoJSON {...} /> 反应元素,但没有成功。(我正在使用react-leaflet + Typescript)使用常规js,我只需要做类似的事情:
<Map
{...}
<GeoJSON
data={...} <- Here I put my feature in JSON format
style={...} <- Associated style
/>
/>
Run Code Online (Sandbox Code Playgroud)
但在 Typescript 中,如果我尝试执行完全相同的操作,则会遇到以下错误:
No overload matches this call.
Overload 1 of 2, '(props: Readonly<GeoJSONProps>): GeoJSON<GeoJSONProps, GeoJSON<any>>', gave the following error.
Type '{ type: string; geometry: { type: string; coordinates: number[]; }; }' is not assignable to type 'GeoJsonObject'.
Object literal may only specify known properties, and 'geometry' does not exist in type …Run Code Online (Sandbox Code Playgroud)