File tree Expand file tree Collapse file tree
advanced-markers-accessibility
weather-api-current-compact Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ async function initMap() {
6464 // [END maps_advanced_markers_accessibility_marker]
6565 // [START maps_advanced_markers_accessibility_event_listener]
6666 // Add a click listener for each marker, and set up the info window.
67- marker . addListener ( ' click', ( { domEvent, latLng } ) => {
67+ marker . addEventListener ( 'gmp- click', ( domEvent ) => {
6868 const { target } = domEvent ;
6969 infoWindow . close ( ) ;
7070 infoWindow . setContent ( marker . title ) ;
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ async function initMap(): Promise<void> {
155155 } ) ;
156156
157157 // Add click listener to the marker
158- marker . addListener ( ' click', ( ) => {
158+ marker . addEventListener ( 'gmp- click', ( ) => {
159159 infoWindow . close ( ) ;
160160 const content = `
161161 <div>Location: ${ latLng . lat ( ) . toFixed ( 3 ) } , ${ latLng . lng ( ) . toFixed ( 3 ) } </div>
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ async function initMap() {
2424 position : center ,
2525 map : innerMap ,
2626 title : 'Click to zoom' ,
27+ gmpClickable : true ,
2728 } ) ;
2829
2930 innerMap . addListener ( 'center_changed' , ( ) => {
@@ -35,7 +36,7 @@ async function initMap() {
3536 } ) ;
3637
3738 // Zoom in when the marker is clicked.
38- marker . addListener ( 'click' , ( ) => {
39+ marker . addListener ( 'gmp- click' , ( ) => {
3940 innerMap . setZoom ( 8 ) ;
4041 innerMap . setCenter ( marker . position as google . maps . LatLng ) ;
4142 } ) ;
Original file line number Diff line number Diff line change @@ -57,9 +57,10 @@ async function initMap(): Promise<void> {
5757 map : map ,
5858 collisionBehavior :
5959 google . maps . CollisionBehavior . REQUIRED_AND_HIDES_OPTIONAL ,
60+ gmpClickable : true ,
6061 } ) ;
6162
62- marker . addListener ( ' click', ( ) => {
63+ marker . addEventListener ( 'gmp- click', ( ) => {
6364 infowindow . open ( map , marker ) ;
6465 } ) ;
6566
Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ async function createAndAddMarker(
139139 position : { lat : location . lat , lng : location . lng } ,
140140 content : weatherWidget ,
141141 title : location . name , // Add a title for accessibility
142+ gmpClickable : true ,
142143 } ) ;
143144
144145 // Store the marker type
@@ -152,7 +153,7 @@ async function createAndAddMarker(
152153 ) ;
153154
154155 // Add click listener to the marker
155- marker . addListener ( ' click', ( ) => {
156+ marker . addEventListener ( 'gmp- click', ( ) => {
156157 const widgetContainer = weatherWidget . shadowRoot ! . querySelector (
157158 '.widget-container'
158159 ) as HTMLDivElement ;
You can’t perform that action at this time.
0 commit comments