|
| 1 | +/* |
| 2 | +* @license |
| 3 | +* Copyright 2025 Google LLC. All Rights Reserved. |
| 4 | +* SPDX-License-Identifier: Apache-2.0 |
| 5 | +*/ |
| 6 | + |
| 7 | +// @ts-nocheck |
| 8 | +// [START maps_3d_accessibility_features] |
| 9 | +async function initMap() { |
| 10 | + const { Map3DElement, Marker3DInteractiveElement, PopoverElement } = await google.maps.importLibrary("maps3d"); |
| 11 | + const { PinElement } = await google.maps.importLibrary("marker"); |
| 12 | + |
| 13 | + const map = new Map3DElement({ |
| 14 | + center: { lat: 34.8405, lng : -111.7909, altitude: 1322.70 }, range: 13279.50, tilt: 67.44 ,heading: 0.01, |
| 15 | + mode: 'SATELLITE' |
| 16 | + }); |
| 17 | + |
| 18 | + // Set LatLng and title text for the markers. The first marker (Boynton Pass) |
| 19 | + // receives the initial focus when tab is pressed. Use arrow keys to move |
| 20 | + // between markers; press tab again to cycle through the map controls. |
| 21 | + const tourStops = [ |
| 22 | + { |
| 23 | + position: { lat: 34.8791806, lng: -111.8265049 }, |
| 24 | + title: "Boynton Pass", |
| 25 | + }, |
| 26 | + { |
| 27 | + position: { lat: 34.8559195, lng: -111.7988186 }, |
| 28 | + title: "Airport Mesa", |
| 29 | + }, |
| 30 | + { |
| 31 | + position: { lat: 34.832149, lng: -111.7695277 }, |
| 32 | + title: "Chapel of the Holy Cross", |
| 33 | + }, |
| 34 | + { |
| 35 | + position: { lat: 34.823736, lng: -111.8001857 }, |
| 36 | + title: "Red Rock Crossing", |
| 37 | + }, |
| 38 | + { |
| 39 | + position: { lat: 34.800326, lng: -111.7665047 }, |
| 40 | + title: "Bell Rock", |
| 41 | + }, |
| 42 | + ]; |
| 43 | + |
| 44 | + tourStops.forEach(({ position, title }, i) => { |
| 45 | + const pin = new PinElement({ |
| 46 | + glyph: `${i + 1}`, |
| 47 | + scale: 1.5, |
| 48 | + glyphColor: "#FFFFFF" |
| 49 | + }); |
| 50 | + const popover = new PopoverElement({ |
| 51 | + open: true, |
| 52 | + }); |
| 53 | + |
| 54 | + const content = `${i + 1}. ${title}`; |
| 55 | + const header = document.createElement('span'); |
| 56 | + // Include the label for screen readers. |
| 57 | + header.ariaLabel = `This is marker ${i + 1}. ${title}`; |
| 58 | + header.slot = 'header'; |
| 59 | + |
| 60 | + popover.append(header); |
| 61 | + popover.append(content); |
| 62 | + |
| 63 | + const interactiveMarker = new Marker3DInteractiveElement({ |
| 64 | + position, |
| 65 | + gmpPopoverTargetElement: popover |
| 66 | + }); |
| 67 | + |
| 68 | + interactiveMarker.append(pin); |
| 69 | + |
| 70 | + map.append(interactiveMarker); |
| 71 | + map.append(popover); |
| 72 | + }); |
| 73 | + |
| 74 | + document.body.append(map); |
| 75 | +} |
| 76 | + |
| 77 | +initMap(); |
| 78 | +// [END maps_3d_accessibility_features] |
0 commit comments