我现在制作的谷歌地图与反应,我有一个问题,显示结果从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>我想在placeId中显示InfoWindow中的地址,并显示{marker.title}。我不知道怎么做..。下面是GitHub存储库上这个项目的链接:https://github.com/hajczek/Neighborhood---Warsaw-Cultural-Map --也许你们中的一些人知道,如何解决这个问题.谢谢你的回答:)
发布于 2018-05-25 16:39:28
我用这种方法解决了这个问题:
document.getElementById('address').textContent = address;我把这段代码写成了“那么”的一部分:
.then(results => {
const address = results[0].formatted_address;
console.log(address);
document.getElementById('address').textContent = address;
})https://stackoverflow.com/questions/50533149
复制相似问题