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
|
const MAPS_KEY = "AIzaSyCtS6CiOrG95FhroSUdDJJokItndcMkrgc";
// Initialize and add the map
let map;
async function initMap() {
// The location of Uluru
const position = { lat: 51.508616, lng: -0.125319 };
// Request needed libraries.
//@ts-ignore
const { Map } = await google.maps.importLibrary("maps");
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker");
// The map, centered at Uluru
map = new Map(document.getElementById("map"), {
zoom: 7,
center: position,
mapId: "DEMO_MAP_ID",
restriction: {
latLngBounds: {
north: 51.74,
south: 51.27,
west: -0.51,
east: 0.23,
},
// strictBounds: true,
},
});
// The marker, positioned at Uluru
const marker = new AdvancedMarkerElement({
map: map,
position: position,
title: "Uluru",
});
}
initMap();
|