Using React JS in Meteor 1.5
Question: Need a way to add Marker using react-google-maps
Using ES6 and in JSX format
Followed the documentation and was able to get the map embedded in, but not able to add the marker.
Here is my code:
const InitialMap = withGoogleMap(props => {
var index = this.marker.index || [];
return(
<GoogleMap
ref={props.onMapLoad}
defaultZoom={14}
defaultCenter={{lat: 40.6944, lng:-73.9213}}
>
<Marker
key={index}
position={marker.position}
onClick={() => props.onMarkerClick(marker)}
/>
</GoogleMap>
)
});
export default class MapContainer extends Component{
constructor(props){
this.state = {
markers:[{
position:{
lat: 255.0112183,
lng:121.52067570000001,
}
}]
}
}
render(){
return(
<div style={{height:"100%"}}>
<InitialMap
containerElement={
<div style={{height:"100%"}}/>
}
mapElement={
<div style={{height:"100%"}} />
}
markers={this.state.markers} />
</div>
)
}
}
I'd check over your lat, lng coordinates again. From google explaining coordinates
"Check that the first number in your latitude coordinate is between -90 and 90."
Also any other error info would be helpful getting an answer for you.
Added the first constant
Changed the containerElement size and mapElement size to pixels instead of percentage
And just adding marker to the function which was called