-
Notifications
You must be signed in to change notification settings - Fork 823
/
index.ts
127 lines (118 loc) · 3.25 KB
/
index.ts
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
// [START maps_js_local_context_styles]
let map: google.maps.Map;
const center = { lat: 21.27869, lng: -157.826347 };
const styles: google.maps.MapTypeStyle[] = [
{ elementType: "geometry", stylers: [{ color: "#efe6be" }] },
{ elementType: "labels.icon", stylers: [{ visibility: "off" }] },
{
elementType: "labels.text.fill",
stylers: [{ color: "#f5f5f5" }, { weight: 1.5 }],
},
{
elementType: "labels.text.stroke",
stylers: [{ color: "#9e9e9e" }, { weight: 1.5 }],
},
{
featureType: "administrative.land_parcel",
stylers: [{ visibility: "off" }],
},
{
featureType: "administrative.land_parcel",
elementType: "labels.text.fill",
stylers: [{ color: "#bdbdbd" }],
},
{
featureType: "administrative.neighborhood",
stylers: [{ visibility: "off" }],
},
{
featureType: "poi",
elementType: "geometry",
stylers: [{ color: "#c44135" }],
},
{
featureType: "poi.park",
elementType: "geometry",
stylers: [{ color: "#328829" }],
},
{
featureType: "poi.sports_complex",
elementType: "geometry",
stylers: [{ color: "#2ca37b" }],
},
{
featureType: "road",
elementType: "geometry",
stylers: [{ color: "#e4b083" }],
},
{
featureType: "road",
elementType: "labels",
stylers: [{ visibility: "off" }],
},
{
featureType: "water",
elementType: "geometry",
stylers: [{ color: "#32cbb1" }],
},
{
featureType: "water",
elementType: "labels.text",
stylers: [{ visibility: "off" }],
},
{
featureType: "water",
elementType: "labels.text.fill",
stylers: [{ color: "#9e9e9e" }],
},
];
function initMap() {
const localContextMapView = new google.maps.localContext.LocalContextMapView({
element: document.getElementById("map"),
placeTypePreferences: [
{ type: "bakery", weight: 1 },
{ type: "park", weight: 2 },
{ type: "restaurant", weight: 3 },
{ type: "shopping_mall", weight: 1 },
{ type: "tourist_attraction", weight: 3 },
],
maxPlaceCount: 18,
directionsOptions: { origin: center },
});
map = localContextMapView.map!;
// Trigger hidePlaceDetailsView() with a click event handler on the inner map.
map.addListener("click", () => {
localContextMapView.hidePlaceDetailsView();
});
// [START maps_js_local_context_styles_merge]
// Merge map styles.
const mergedStyles = map.get("styles").concat(styles);
map.setOptions({
center: center,
zoom: 14,
styles: mergedStyles,
});
// [END maps_js_local_context_styles_merge]
// [START maps_js_local_context_styles_marker]
// Add a marker at the center point
new google.maps.Marker({
position: center,
map: map,
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAdUlEQVR4AWMYOWAU/AfhYWMBCxA3A/FlIN4MxN7I6gjg80DcD8QC+CzIxqIxH6aOSHwfYQmmBZexuQymjgTcj8uCz1gUHybDgvO4LFiMRXE4GRb8x2UBDxCXQ8PxPdSrLNSxAD+g3ALCeNQCKoHhZcHAg1EAAM3cyWj3TGxhAAAAAElFTkSuQmCC",
zIndex: 30,
});
// [END maps_js_local_context_styles_marker]
}
declare global {
interface Window {
initMap: () => void;
}
}
window.initMap = initMap;
// [END maps_js_local_context_styles]
export {};