ドキュメント - https://github.com/tomchentw/react-google-maps/tree/v5.1.0#documentation - マーカーに「アニメーション」を追加できると言います。しかし、私はアニメーションを追加する方法を把握していないようです。私が追加しようとした他のプロパティもありますが、できませんでした。"react-google-maps"のマーカーにアニメーションを追加するにはどうすればいいですか?
const ProvidenceMap = withGoogleMap(props => (
<GoogleMap
defaultZoom={13}
defaultCenter={{ lat: 41.8240, lng: -71.4128 }}
>
{props.markers.map((marker, index) => (
<Marker
key={index}
position={marker.position}
onClick={() => props.onMarkerClick(marker)}
animation={marker.animation}
>
{marker.showInfo && (
<InfoWindow onCloseClick={() => props.onMarkerClose(marker)}>
{
<div className="info-window">this is the info window</div>
}
</InfoWindow>
)}
</Marker>
))};
</GoogleMap>
));
class ContentContainer extends React.Component {
constructor() {
super();
this.state = {
landing: true,
map: false,
wishListTitle: "",
markers: [
{
position: {lat: 41.8240, lng:-71.4128},
showInfo: false,
animation: "DROP",
},
{
position: {lat: 41.8250, lng: -71.4338},
showInfo: false,
animation: "DROP",
}
],
}
}
/* click handlers and render() have been omitted for simplicity */
}
返信いただきありがとうございます!しかし、私は今、 "'google'が定義されていないというエラーが表示されています。私は次のものに加えて何かを輸入すべきですか? {Googleマップ、Googleマップ、マーカー、情報ウィンドウ、アニメーション、} –
Google Maps JavaScript APIを読み込んでいる場合は、[README](https://github.com/tomchentw/react-google-maps/tree/v5 .1.0#loading-libraries)、(問題のコードが実行される前に読み込まれています)、googleはブラウザのグローバルスコープに存在するはずです。それがなければ、私はそれがなぜ起こるのか分からない。 –
ちょっと分かりました!私は、HTMLファイルの先頭にAPIを同期的に読み込むだけでなく、/ *グローバルgoogle * /をjsファイルの先頭に追加する必要がありました。ご協力いただきありがとうございます! –