React-TypeScript:属性 'position' 在类型 'IntrinsicAttributes & IntrinsicClassAttributes<GoogleMapReact> 上不存在

React-TypeScript: Property 'position' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<GoogleMapReact>

我正在学习 React-typescript。我正在使用 React google 地图来显示我的区域。我成功地能够显示地图。当我尝试使用 react-google-map 中的 Marker 来指出我的区域并定位我的经纬度时。我收到打字稿错误: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)`
`;

请记住,google-map-react 允许您在地图上呈现 任何 React 组件
该库不导出 Marker 组件。
但是,如果您想使用默认的 Google 地图标记,您可以查看解决方案 .
根据文档中的示例,您应该能够通过定义自己的 自己的标记组件 来实现类似的目的:

import React, { Component } from 'react';
import GoogleMapReact from 'google-map-react';

const Marker = ({ text }) => <div>{text}</div>;

class SimpleMap extends Component {
  static defaultProps = {
    center: {
      lat: 59.95,
      lng: 30.33
    },
    zoom: 11
  };

  render() {
    return (
      <div style={{ height: '100vh', width: '100%' }}>
        <GoogleMapReact
          bootstrapURLKeys={{ key: /* YOUR KEY HERE */ }}
          defaultCenter={this.props.center}
          defaultZoom={this.props.zoom}
        >
          <Marker
            lat={59.955413}
            lng={30.337844}
            text="My Marker"
          />
        </GoogleMapReact>
      </div>
    );
  }
}

export default SimpleMap;
Mac: sudo npm install @ionic-native/geolocation@5.27.0

window:npm install @ionic-native/geolocation@5.27.0