【发布时间】:2018-05-26 00:39:28
【问题描述】:
我现在正在制作一个带有 react 的谷歌地图,但我的 placeId 显示结果有问题。我有这个代码:
<Marker
{...marker}
key={i}
position={marker.location}
title={marker.title}
icon={'icons/' + marker.type + '.png'}
onClick={() => {
props.toggleLocationsActive(i);
}}
//animation={DROP}
>
{i === props.activeKey && (
geocodeByPlaceId(marker.place_id)
.then(results => {
const address = results[0].formatted_address;
console.log(address);
})
.catch(error => console.error(error)),
<InfoWindow onCloseClick={props.onToggleOpen}>
<div>{ marker.title }</div>
</InfoWindow>)}
</Marker>
我想在 InfoWindow 中显示取自这个 placeId 的地址 - 并显示 {marker.title}。而且我不知道该怎么做...这是GitHub存储库上该项目的链接:https://github.com/hajczek/Neighborhood---Warsaw-Cultural-Map也许你们中的一些人知道,如何解决这个问题...感谢您的任何回答:)
【问题讨论】:
-
我通过这种方式解决了这个问题:document.getElementById('address').textContent = address;
标签: reactjs google-maps google-places react-google-maps