map-react热图。我能够通过props第一次显示热层,但无法更新数据变化的地图。任何帮助将不胜感激。
我正在使用google-map-react。我尝试过通过道具和状态传递数据。
<GoogleMapReact
ref={(el) => this._googleMap = el}
bootstrapURLKeys={{ key:"MY_API_KEY",libraries: ['visualization'] }}
defaultCenter={this.props.center}
defaultZoom={this.props.zoom}
heatMapLibrary={true}
heatMapData={this.props.heatMapData}
yesIWantToUseGoogleMapApiInternals
onGoogleApiLoaded={({map, maps}) => {
let heatmap = new maps.visualization.HeatmapLayer({
data: this.props.heatData.map(point => (
{location: new maps.LatLng(point['location'][1], point['location'][0]),
weight: point['weight']}))
});
heatmap.setMap(map);
}}
>
</GoogleMapReact>