reactjs - 谷歌地图上的信息窗口不显示
问题描述
我遵循了此处发布的一些建议,但似乎无法让 InfoWindows 在地图上显示。但连标记都没有出现?但是 api 调用正在返回正确的数据..
这是我的大部分代码,减去 api 调用,这不是问题的原因。任何帮助都会很棒!提前致谢 :)
<Map
google={this.props.google}
zoom={5}
style={style}
gestureHandling={'cooperative'}
initialCenter={{
lat: -19.577286,
lng: 147.406473
}}
>
{this.state.data.map((result) => {
let keys = Object.keys(result);
return keys.map(data => {
return (
<>
<Marker
name={result[data].item1}
title={result[data].item2}
onClick={ this.onMarkerClick }
position={{
lat: result[data].lat,
lng: result[data].long
}}
animation={this.props.google.maps.Animation.DROP}
/>
<InfoWindow
marker = { this.state.activeMarker }
visible = { this.state.showingInfoWindow } >
<div>
<h4>{ this.state.selectedPlace.title }</h4>
<p>{ this.state.selectedPlace.name }</p>
</div>
</InfoWindow>
</>
);
});
})}
</Map>
解决方案
推荐阅读
- wordpress - FacetWP 显示所有选项和方面
- windows - 在 Windows 上检测传入的 UDP 流
- r - 将ggplots存储为R中的“变量”
- javascript - 反应中的setState增量和每个增量1有什么区别
- javascript - React Native + React I18next + React Navigation、navigationOptions 更新问题
- angular - Angular 6 getRawValue() 不会返回禁用值
- r - 使用 mutate_at 对多个变量进行 Boxcox 变换
- python - 检查是否在python中启用了PIE
- sqlite - Ionic 3 本机 SQLite 插件未按预期工作
- python - 在 Flask 中使用 Response 对象时捕获异常不起作用