Comments (8)
We're in a bit of a transition-period right now – the version currently in beta will introduce the web-components (<gmp-map>
and <gmp-advanced-marker>
), and with that we'll probably also get support for DOM events on the AdvancedMarkerElement
itself.
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 advancedMarker.element
instead. We probably don't even need a different handling of this for when web-components are released, but that remains to be seen.
from react-google-maps.
Unfortunately, that doesn't work if your content is just a Pin
component. I should be able to look into this tomorrow.
from react-google-maps.
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 :)
from react-google-maps.
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>
from react-google-maps.
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:
- Pass version as beta in APIProvider prop
- The AdvancedMarker component extends for all EventListener.
- The user passes any listener as prop, let say onMouseEnter
- If APIProvider is initialized in beta mode then we allow this events, else give error saying that its still in beta and needs to initialize APIProvider in beta version.
The benefit of this approach is that we don't have to manually add each listener to the components like AdvancedMarker
or Pin
from react-google-maps.
Is there any example of adding listeners to the advancedMarker.element
or does it need to be built?
from react-google-maps.
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.
from react-google-maps.
Earlier it made sense to add each declaration because the type of events was MapMouseEvent
and not the native events emitted by the element. But as per the docs, they will be emitting native events so I think it will be better to go the native way.
from react-google-maps.
Related Issues (20)
- [Feat] Add ability to cache map-instances to be re-used when remounted
- [Feat] Add support for the mobile gesture double tap + hold + drag up/down to zoom HOT 1
- [Feat] Replace useMemo with useState for one time initializations HOT 2
- Use the API libraries without the need of using a map first [Feat] HOT 5
- [Feat] AdvancedMarker: add style prop HOT 1
- Map returned undefined HOT 4
- [Bug]Cannot remove a WebglOverlay
- [Bug] AdvancedMarker className prop should also be applied when using a Pin instead of custom content
- <ApiProvider> failed to load Google Maps API Error HOT 4
- [Feat] Add support for InfoWindow headerContent / headerDisabled options HOT 10
- Add className and style prop to the MapControl component HOT 1
- [Bug] Warning: useLayoutEffect does nothing on the server HOT 4
- [Bug] InfoWindow anchor reference not cleared on unmount HOT 8
- How can I animate the route to show a pulsating trail? HOT 5
- [Bug] Open two infowindow when clicking the marker HOT 1
- [Feat] Add padding option to defaultBounds HOT 5
- [Feat] Change the language HOT 1
- [Bug] On clicking AdvanceMarker to open InfoWindow, goes into an Infinite loop of rendering on setting markerRef(marker) manually HOT 8
- Marker icons are showing along with marker cluster HOT 2
- [Bug] Infinite loop using AdvancedMarkers when the marker items are changed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-google-maps.