refactor: migrate AdvancedMarkerElement to native DOM events - #1653
Open
willum070 wants to merge 2 commits into
Open
refactor: migrate AdvancedMarkerElement to native DOM events#1653willum070 wants to merge 2 commits into
willum070 wants to merge 2 commits into
Conversation
…ative DOM events Change-Id: I8977020fc4d94e5edced2a1e17308b19a9cefd5e
jeantimex
reviewed
Aug 31, 2026
Change-Id: I2cd3b4946fda3ade0a7e05ae1ba0e2a17daecd76
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
As the Maps JavaScript API increasingly adopts Web Components, it's recommended to use native DOM events over the legacy
google.maps.eventwrapper for elements likeAdvancedMarkerElement. This PR updates our samples to align with these modern best practices.Key Changes
addListener()method with nativeaddEventListener()across allAdvancedMarkerElements in the repository.clickevent bindings to use the nativegmp-clickDOM event.dragendevent inadvanced-markers-draggableandpolyline-utilityto use the nativegmp-dragendDOM event.event.clearInstanceListeners()cleanup call inpolyline-utility. Because the markers are native DOM nodes that get cleanly discarded (spliced from state andmap = null), any attached nativegmp-event listeners are naturally garbage collected, rendering explicit cleanup unnecessary.eventimports from thegoogle.maps.importLibrary('core')destructuring assignments.Affected Samples (11 total)
advanced-markers-draggableadvanced-markers-htmlai-powered-summaries-basicevent-closureplace-nearby-searchplace-text-searchpolyline-utilityui-kit-advanced-place-search-nearbyui-kit-advanced-place-search-textui-kit-place-search-nearbyui-kit-place-search-textTesting
npm starttested successfully).addListener('click')bindings remain on any Marker elements.Change-Id: I8977020fc4d94e5edced2a1e17308b19a9cefd5e