我正在学习 React 打字稿。我正在使用反应谷歌地图来显示我的区域。我成功地能够显示地图。当我尝试使用 react-google-map 中的标记来指出我的区域并定位我的纬度和经度时。我收到打字稿错误:Property 'position' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<GoogleMapReact> & Readonly<Props> & Readonly<...>
。我真的不知道如何解决它。
import React, { useEffect, useState } from 'react';
import styled from 'styled-components';
import ErrorBoundary from 'components/errorBoundary';
import GoogleMapReact from 'google-map-react';
import Marker from 'google-map-react'
export interface ITestNewListProps {
className?: string;
position?: { lat: number; lng: number; };
}
const TestMaps = ({ className, position }: ITestNewListProps) => {
const [state, setstate] = useState(
{
center: {
lat: 60.1098678,
lng: 24.7385084
},
zoom: 7
}
)
return (
<ErrorBoundary id="TestNewListErrorBoundary">
<div className={`${className}`}>
<div style={{ height: '100vh', width: '100%' }}>
<GoogleMapReact
bootstrapURLKeys={{ key: "*************************" }}
defaultCenter={state.center}
defaultZoom={state.zoom}
>
<Marker position={{ lat: 60.1098678, lng: 24.7385084 }} />//Geting error from here
</GoogleMapReact>
</div>
</div>
</ErrorBoundary>
);
};
TestMaps.displayName = `test`;
export default styled(TestMaps)`
`;