Skip to content

Commit 5a9dc53

Browse files
committed
feat: Updates sample to use gmp-map element.
Change-Id: I85acd733a5a79b705a0695ba3bf0fca26fadbd20
1 parent 2a7918e commit 5a9dc53

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

samples/advanced-markers-accessibility/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
<link rel="stylesheet" type="text/css" href="./style.css" />
1313
<script type="module" src="./index.js"></script>
14-
</head>
15-
<body>
16-
<div id="map"></div>
1714

1815
<!-- prettier-ignore -->
1916
<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))})
2017
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "beta"});</script>
18+
</head>
19+
<body>
20+
<gmp-map zoom="12" center="34.84555,-111.8035" map-id="4504f8b37365c3d0"></gmp-map>
2121
</body>
2222
</html>
2323
<!-- [END maps_advanced_markers_accessibility] -->

samples/advanced-markers-accessibility/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55
*/
66

77
// [START maps_advanced_markers_accessibility]
8+
const mapElement = document.querySelector('gmp-map') as google.maps.MapElement;
9+
let innerMap;
10+
811
async function initMap() {
912
// Request needed libraries.
1013
const { Map, InfoWindow } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
1114
const { AdvancedMarkerElement, PinElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;
1215

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

1918
// Set LatLng and title text for the markers. The first marker (Boynton Pass)
2019
// receives the initial focus when tab is pressed. Use arrow keys to move
@@ -54,7 +53,7 @@ async function initMap() {
5453
// [START maps_advanced_markers_accessibility_marker]
5554
const marker = new AdvancedMarkerElement({
5655
position,
57-
map,
56+
map: innerMap,
5857
title: `${i + 1}. ${title}`,
5958
content: pin.element,
6059
gmpClickable: true,

0 commit comments

Comments
 (0)