-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.ts
More file actions
40 lines (32 loc) · 1.06 KB
/
index.ts
File metadata and controls
40 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @license
* Copyright 2026 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
// [START maps_layer_data_event]
let map: google.maps.Map;
async function initMap() {
(await google.maps.importLibrary('maps')) as google.maps.MapsLibrary;
const mapElement = document.querySelector(
'gmp-map'
) as google.maps.MapElement;
const innerMap = mapElement.innerMap;
// Load GeoJSON.
innerMap.data.loadGeoJson('google.json');
// Add some style.
innerMap.data.setStyle((feature) => {
return /** @type {google.maps.Data.StyleOptions} */ {
fillColor: feature.getProperty('color') as string,
strokeWeight: 1,
};
});
// [START maps_layer_data_event_snippet]
// Set mouseover event for each feature.
innerMap.data.addListener('mouseover', (event) => {
(document.getElementById('info-box') as HTMLElement).textContent =
event.feature.getProperty('letter');
});
// [END maps_layer_data_event_snippet]
}
initMap();
// [END maps_layer_data_event]