The*_*oul 5 google-maps typescript reactjs
我正在尝试使用这个库“react-google-maps”在我的应用程序中显示谷歌地图。从他们的 github 页面按照教程进行操作后,我在第一次运行时收到此错误(这是一个 create-react-app + typescript 应用程序):
我有点迷失在这里。以前有人用过这个库吗?这是我的代码:
import * as React from 'react';
import { GoogleMap, Marker, withGoogleMap, withScriptjs } from 'react-google-maps';
import { compose, withProps } from 'recompose';
const TerrMap: React.StatelessComponent<{
isMarkerShown: boolean
}> = compose(
withProps({
googleMapURL: "https://maps.googleapis.com/maps/api/js?key=__my_api_key__&v=3.exp&libraries=geometry,drawing,places",
loadingElement: <div style={{ height: `100%` }} />,
containerElement: <div style={{ height: `400px` }} />,
mapElement: <div style={{ height: `100%` }} />,
}),
withScriptjs,
withGoogleMap
)( (props: any) => {
return (
<GoogleMap
defaultZoom={8}
defaultCenter={{ lat: -34.397, lng: 150.644 }}
>
{props.isMarkerShown && <Marker position={{ lat: -34.397, lng: 150.644 }} />}
</GoogleMap>
);
} ) as any;
Run Code Online (Sandbox Code Playgroud)
小智 8
如果这还没有得到回答。这是解决此问题的方法。
"@types/googlemaps"和"@types/markerclustererplus"——
{
"compilerOptions":{
...,
"types":[
...
"googlemaps",
"markerclustererplus"
]
}
}
Run Code Online (Sandbox Code Playgroud)
这应该可以解决您的问题。
| 归档时间: |
|
| 查看次数: |
2056 次 |
| 最近记录: |