<Marker> not displayed if wrapped by another React component
hipertracker opened this issue · 3 comments
Why (I use the example from README) does not show up on the map when it's a part of another React component? Even simple stateless component is not displayed on the map. Am I missing something?
This works:
<Gmaps ....><Marker lat={coords.lat} lng={coords.lng}/></Gmaps>
This does not work (the marker is not displayed on the map):
const Marker2 = ({lat, lng}) => <Marker lat={lat} lng={lng}/>
<Gmaps ....><Marker2 lat={coords.lat} lng={coords.lng}/></Gmaps>
Hmm, I found the problem. Marker is a React component but it does not render anything. The render()
method returns null
. It only provides some binding to Google Maps API. I need to reconsider the way of building higher order component here.
If you could get the map instance, you could just manually add it in by creating a marker object using google.map.Marker({})
and using marker.setMap(map)
I can get map instance. Yes, I can built it that way.