-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (31 loc) · 983 Bytes
/
index.js
File metadata and controls
31 lines (31 loc) · 983 Bytes
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
"use strict";
/**
* @license
* Copyright 2026 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
// [START maps_layer_data_event]
let map;
async function initMap() {
(await google.maps.importLibrary('maps'));
const mapElement = document.querySelector('gmp-map');
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'),
strokeWeight: 1,
};
});
// [START maps_layer_data_event_snippet]
// Set mouseover event for each feature.
innerMap.data.addListener('mouseover', (event) => {
document.getElementById('info-box').textContent =
event.feature.getProperty('letter');
});
// [END maps_layer_data_event_snippet]
}
initMap();
// [END maps_layer_data_event]