Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions samples/advanced-markers-accessibility/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>
</head>
<body>
<div id="map"></div>

<!-- prettier-ignore -->
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "beta"});</script>
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
</head>
<body>
<gmp-map zoom="12" center="34.84555,-111.8035" map-id="4504f8b37365c3d0"></gmp-map>
</body>
</html>
<!-- [END maps_advanced_markers_accessibility] -->
14 changes: 7 additions & 7 deletions samples/advanced-markers-accessibility/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
*/

// [START maps_advanced_markers_accessibility]
const mapElement = document.querySelector('gmp-map') as google.maps.MapElement;
let innerMap;

async function initMap() {
// Request needed libraries.
const { Map, InfoWindow } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
const { AdvancedMarkerElement, PinElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;

const map = new Map(document.getElementById("map") as HTMLElement, {
zoom: 12,
center: { lat: 34.84555, lng: -111.8035 },
mapId: '4504f8b37365c3d0',
});
innerMap = mapElement.innerMap;

// Set LatLng and title text for the markers. The first marker (Boynton Pass)
// receives the initial focus when tab is pressed. Use arrow keys to move
Expand Down Expand Up @@ -54,11 +53,12 @@ async function initMap() {
// [START maps_advanced_markers_accessibility_marker]
const marker = new AdvancedMarkerElement({
position,
map,
title: `${i + 1}. ${title}`,
content: pin.element,
gmpClickable: true,
});

mapElement.append(marker);
// [END maps_advanced_markers_accessibility_marker]
// [START maps_advanced_markers_accessibility_event_listener]
// Add a click listener for each marker, and set up the info window.
Expand All @@ -73,4 +73,4 @@ async function initMap() {
}

initMap();
// [END maps_advanced_markers_accessibility]
// [END maps_advanced_markers_accessibility]