我想使用react-google-maps的
HeatmapLayer
,但我遇到了以下错误:
我一直在努力让这个东西工作,但是我没有找到解决方法。同时,在这个链接中也没有什么有用的信息: (https://github.com/tomchentw/react-google-maps/issues/409)Uncaught (in promise) TypeError: Cannot read property 'HeatmapLayer' of undefined
import {withGoogleMap,GoogleMap} from "react-google-maps"
import HeatmapLayer from "react-google-maps/lib/visualization/HeatmapLayer"
render(){
var data = [new window.google.maps.LatLng(37.782551, -122.445368),
new window.google.maps.LatLng(37.782745, -122.444586),
new window.google.maps.LatLng(37.782842, -122.443688),
new window.google.maps.LatLng(37.782919, -122.442815),
new window.google.maps.LatLng(37.782992, -122.442112),
new window.google.maps.LatLng(37.783100, -122.441461)
]
const Heatmap = withGoogleMap(props => (
<GoogleMap
defaultZoom={1}
center={{lat: 19.435031,lng: -99.167357}}
>
<HeatmapLayer data = {data} />
</GoogleMap>));
return(
<div className="googleMap">
<Heatmap
containerElement={
<div style={{ height: `100%` }} />
}
mapElement={
<div style={{ height: `100%` }} />
}
center={{ lat: -25.363882, lng: 131.044922 }}
/>
</div>)
}
}