-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] Add Support for onMouseOver and onMouseLeave props in <AdvancedMarker />
#304
Comments
I ran into this too. You can work around this by adding the props to your AdvancedMarker content, for example; <AdvancedMarker
ref={markerRef}
position={markerPosition}
onClick={() => setInfowindowOpen(true)}
{...other}
>
<div
onMouseOver={() => setInfowindowOpen(true)}
onMouseOut={() => setInfowindowOpen(false)}
style={{
width: 20,
height: 20,
position: 'absolute',
top: 0,
left: 0,
background: '#F00',
border: `2px solid #FFF`,
borderRadius: '50%',
transform: 'translate(-50%, -50%)'
}}
/>
{infowindowOpen && (
<InfoWindow
anchor={marker}
maxWidth={200}
onCloseClick={() => setInfowindowOpen(false)}
>
infowindow content
</InfoWindow>
)}
</AdvancedMarker> |
Unfortunately, that doesn't work if your content is just a |
Were you able to look into it @usefulthink. I was looking into the API reference for AdvanceMarker here. Seems that the addEventListener method is part of beta version as of now. The APIProvider component does allow us to pass version as prop. Was wondering if this will work:
The benefit of this approach is that we don't have to manually add each listener to the components like |
We're in a bit of a transition-period right now – the version currently in beta will introduce the web-components ( But I wouldn't want to make the beta-channel a requirement for using AdvancedMarker, if we can solve this in another way. Until the web-components are in GA (weekly and quarterly channels), the best thing to do is probably to add the event-listeners to the |
Is there any example of adding listeners to the |
No, it's on my ToDo-list, but I haven't gotten to it yet. I'm still pondering if we should use wrapped events for the markers like we do for the map itself, or if we should just use the native events. |
Earlier it made sense to add each declaration because the type of events was |
Yeah, I'm thinking the same. For the map it was necessary because the map-events mostly don't contain any useful data about the event, but here we have perfectly functional DOM-events already :) |
Did anyone ever figure this out, I am following generally what you are saying but don't know how to implement the addition of listener. |
I was able to use this method but was only able to use it after setting version='beta' in the props for APIProvider |
@BParvatkar Can you share a code example of this? I'm unable to make it work how you describe |
Target Use Case
Adding these props would enable developers to build functionality around AdvancedMarker hover states. e.g I'd like to be able to show a preview of some metadata in an InfoWindow when a marker is being hovered over.
Proposal
Add
onMouseOver
andonMouseLeave
as props, similar to the current api ofonClick
and the drag event handlers.The text was updated successfully, but these errors were encountered: