-
Notifications
You must be signed in to change notification settings - Fork 823
/
index.js
50 lines (44 loc) · 1.18 KB
/
index.js
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
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
// [START maps_overlay_remove]
// This example adds a UI control allowing users to remove the
// ground overlay from the map.
let historicalOverlay;
let map;
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
zoom: 13,
center: { lat: 40.74, lng: -74.18 },
});
const imageBounds = {
north: 40.773941,
south: 40.712216,
east: -74.12544,
west: -74.22655,
};
historicalOverlay = new google.maps.GroundOverlay(
"https://storage.googleapis.com/geo-devrel-public-buckets/newark_nj_1922-661x516.jpeg",
imageBounds,
);
// add event listener for click event
document
.getElementById("restore-overlay")
.addEventListener("click", restoreOverlay);
document
.getElementById("remove-overlay")
.addEventListener("click", removeOverlay);
// restore overlay to map
restoreOverlay();
}
function restoreOverlay() {
historicalOverlay.setMap(map);
}
// [START maps_overlay_remove_region_removal]
function removeOverlay() {
historicalOverlay.setMap(null);
}
window.initMap = initMap;
// [END maps_overlay_remove]