-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.ts
More file actions
53 lines (43 loc) · 1.38 KB
/
index.ts
File metadata and controls
53 lines (43 loc) · 1.38 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
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* @license
* Copyright 2025 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* This is the simplest possible data-driven styling example.
* It calls the styling function with a Place ID.
*/
// [START maps_boundaries_simple]
let featureLayer;
async function initMap() {
// Request needed libraries.
await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
// Get the gmp-map element.
const mapElement = document.querySelector(
"gmp-map"
) as google.maps.MapElement;
// Get the inner map.
const innerMap = mapElement.innerMap;
// [START maps_boundaries_simple_get_layer]
// Get the feature layer.
featureLayer = innerMap.getFeatureLayer(google.maps.FeatureType.LOCALITY);
// [END maps_boundaries_simple_get_layer]
// [START maps_boundaries_simple_style_single]
// Define a style with purple fill and border.
const featureStyleOptions: google.maps.FeatureStyleOptions = {
strokeColor: '#810FCB',
strokeOpacity: 1.0,
strokeWeight: 3.0,
fillColor: '#810FCB',
fillOpacity: 0.5
};
// Apply the style to a single boundary.
featureLayer.style = (options: { feature: { placeId: string; }; }) => {
if (options.feature.placeId == 'ChIJ0zQtYiWsVHkRk8lRoB1RNPo') { // Hana, HI
return featureStyleOptions;
}
};
// [END maps_boundaries_simple_style_single]
}
initMap();
// [END maps_boundaries_simple]