How to get all markers in google-maps-react
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKPz5qhCkKGdpPJ0wkSm5JqlliSJoZg92-H4DuCruovhkVFuXerCphZt9wys_Gr3uwQyXObMHDwattjG5BSeCEl_LdDq1GPLct8qYyRyX4fZ9C93oW-TX7IGZLYDwqRgfFCXA4aUxkBAcS/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6VebLk98DYwS3K2nWZSCatab-q4HrSuRk91M4fQA8SHrKU_-x-lq1n780pSU_bIVLqMRv6pc3dhhh-Y2PUwBS9mM0BxvY1eM6XsM-e7Diu4z-wAoeDG0vB3-2_1U9RE8sO0lg4PHiIXbI/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
How to get all markers in google-maps-react
I have the google-maps-react
in my project, but I don't know how to get all markers from the map?
google-maps-react
import React, Component from "react";
import Map, InfoWindow, Marker, GoogleApiWrapper from "google-maps-react";
import "../Body/Map.css";
import marker_icon from "../../img/marker_icon.png";
import hover_icon from "../../img/hover_icon.png";
import Grid, Row, Col from "react-bootstrap";
/*global google*/
export class MapContainer extends Component
constructor(props)
super(props);
this.state =
showingInfoWindow: false,
activeMarker: ,
selectedPlace:
;
onMarkerClick = (props, marker, e) =>
this.setState(
selectedPlace: props,
activeMarker: marker,
showingInfoWindow: true
);
;
onMapClicked = props =>
if (this.state.showingInfoWindow)
this.setState(
showingInfoWindow: false,
activeMarker: null
);
;
addMarker = (mapProps, map) =>
var marker = new google.maps.Marker(
position: ,
map: map
);
;
render()
const google = window.google;
const data = this.props.data;
return (
<div className="map-container">
<Map
google=this.props.google
className="map"
zoom=1
onClick=this.onMapClicked
onReady=this.addMarker
>
data.map(item => (
<Marker
key=item.id
title=item.name
name=item.name
position= lat: item.lat, lng: item.lng
onClick=this.onMarkerClick
/>
))
<InfoWindow
marker=this.state.activeMarker
visible=this.state.showingInfoWindow
>
<div className="info">
<h1>this.state.selectedPlace.name</h1>
</div>
</InfoWindow>
</Map>
</div>
);
export default GoogleApiWrapper(
apiKey: "AIzaSyDLgdweTnvhPnUE5yzdxcMeK876cFtMaSk"
)(MapContainer);
this.props.data
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
What do you mean by "how to get all markers from the map"? You have all the marker data in the
this.props.data
array.– Tholle
1 min ago