Skip to content

Commit 5e474cc

Browse files
committed
fix: Makes more changes to keep sample to match documentation.
1 parent 5e7933c commit 5e474cc

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

samples/js-api-loader-map/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!doctype html>
22
<!--
33
@license
4-
Copyright 2019 Google LLC. All Rights Reserved.
4+
Copyright 2025 Google LLC. All Rights Reserved.
55
SPDX-License-Identifier: Apache-2.0
66
-->
77
<!-- [START maps_js_api_loader_map] -->

samples/js-api-loader-map/index.ts

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
11
/**
22
* @license
3-
* Copyright 2019 Google LLC. All Rights Reserved.
3+
* Copyright 2025 Google LLC. All Rights Reserved.
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

77
// [START maps_js_api_loader_map]
8-
import { setOptions, importLibrary } from "@googlemaps/js-api-loader";
8+
// [START maps_js_api_loader_map_load]
9+
// Import the needed libraries.
10+
import { setOptions, importLibrary } from '@googlemaps/js-api-loader';
11+
// [END maps_js_api_loader_map_load]
912

10-
const API_KEY = "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8";
13+
const API_KEY = 'AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8';
1114

1215
async function initMap(): Promise<void> {
13-
setOptions({ key: API_KEY });
14-
15-
const { Map } = await importLibrary("maps") as google.maps.MapsLibrary;
16-
17-
const mapOptions = {
18-
center: { lat: 48.8566, lng: 2.3522 },
19-
zoom: 3,
20-
};
21-
22-
const map = new Map(document.getElementById("map") as HTMLElement, mapOptions);
23-
16+
// [START maps_js_api_loader_map_options]
17+
// Set loader options.
18+
setOptions({
19+
key: API_KEY,
20+
v: 'weekly',
21+
});
22+
// [END maps_js_api_loader_map_options]
23+
24+
// Load the Maps library.
25+
const { Map } = (await importLibrary('maps')) as google.maps.MapsLibrary;
26+
27+
// Set map options.
28+
const mapOptions = {
29+
center: { lat: 48.8566, lng: 2.3522 },
30+
zoom: 3,
31+
};
32+
33+
// Declare the map.
34+
const map = new Map(
35+
document.getElementById('map') as HTMLElement,
36+
mapOptions
37+
);
2438
}
2539

2640
initMap();
27-
// [END maps_js_api_loader_map]
41+
// [END maps_js_api_loader_map]

samples/js-api-loader-map/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2019 Google LLC. All Rights Reserved.
3+
* Copyright 2025 Google LLC. All Rights Reserved.
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
/* [START maps_js_api_loader_map] */

0 commit comments

Comments
 (0)