Skip to content

Commit

Permalink
feat: Updates example to show use of renderingType option; updates to…
Browse files Browse the repository at this point in the history
… use dynamic library loading.
  • Loading branch information
willum070 committed Sep 19, 2024
1 parent 2e77715 commit 6bf619c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
4 changes: 2 additions & 2 deletions samples/add-map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ async function initMap(): Promise<void> {
const position = { lat: -25.344, lng: 131.031 };

// Request needed libraries.
//@ts-ignore
const { Map } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
const { Map, RenderingType } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;

// The map, centered at Uluru
Expand All @@ -24,6 +23,7 @@ async function initMap(): Promise<void> {
zoom: 4,
center: position,
mapId: 'DEMO_MAP_ID',
renderingType: RenderingType.VECTOR,
}
);
// [END maps_add_map_instantiate_map]
Expand Down
32 changes: 15 additions & 17 deletions samples/webgl-tilt-rotation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
*/

// [START maps_webgl_tilt_rotation]
function initMap(): void {
const map = new google.maps.Map(
async function initMap() {
const { LatLng } = await google.maps.importLibrary("core") as google.maps.CoreLibrary;
const { Map, RenderingType } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;

const center = new LatLng(37.790211, -122.389607); // Downtown San Francisco, CA

const map = new Map(
document.getElementById("map") as HTMLElement,
{
center: {
lat: 37.7893719,
lng: -122.3942,
},
zoom: 16,
heading: 320,
tilt: 47.5,
mapId: "90f87356969d889c",
center,
zoom: 17,
heading: 280,
tilt: 67.5,
renderingType: RenderingType.VECTOR,
}
);

Expand Down Expand Up @@ -52,13 +54,9 @@ function initMap(): void {
break;
}
};

}

declare global {
interface Window {
initMap: () => void;
}
}
window.initMap = initMap;
initMap();
// [END maps_webgl_tilt_rotation]
export {};
export {};
3 changes: 1 addition & 2 deletions samples/webgl-tilt-rotation/webgl-tilt-rotation.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"title": "Tilt and Rotation",
"callback": "initMap",
"libraries": [],
"dynamic_import": "true",
"version": "weekly",
"tag": "webgl_tilt_rotation",
"name": "webgl-tilt-rotation",
Expand Down

0 comments on commit 6bf619c

Please sign in to comment.