Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ <h1>Maps JSAPI Samples</h1>
<li><a href='/samples/place-autocomplete-data-session/dist'>place-autocomplete-data-session</a></li>
<li><a href='/samples/place-autocomplete-element/dist'>place-autocomplete-element</a></li>
<li><a href='/samples/place-autocomplete-map/dist'>place-autocomplete-map</a></li>
<li><a href='/samples/place-class/dist'>place-class</a></li>
<li><a href='/samples/place-text-search/dist'>place-text-search</a></li>
<li><a href='/samples/test-example/dist'>test-example</a></li>
<li><a href='/samples/ui-kit-customization/dist'>ui-kit-customization</a></li>
Expand Down
13 changes: 13 additions & 0 deletions dist/samples/place-class/app/.eslintsrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": [
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"rules": {
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-this-alias": 1,
"@typescript-eslint/no-empty-function": 1,
"@typescript-eslint/explicit-module-boundary-types": 1,
"@typescript-eslint/no-unused-vars": 1
}
}
33 changes: 33 additions & 0 deletions dist/samples/place-class/app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Google Maps JavaScript Sample

This sample is generated from @googlemaps/js-samples located at
https://github.com/googlemaps-samples/js-api-samples.

## Setup

### Before starting run:

`npm i`

### Run an example on a local web server

First `cd` to the folder for the sample to run, then:

`npm start`

### Build an individual example

From `samples/`:

`npm run build --workspace=sample-name/`

### Build all of the examples.

From `samples/`:

`npm run build-all`

## Feedback

For feedback related to this sample, please open a new issue on
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
23 changes: 23 additions & 0 deletions dist/samples/place-class/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<!--
@license
Copyright 2019 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!-- [START maps_place_class] -->
<html>
<head>
<title>Place Class</title>

<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>
</head>
<body>
<div id="map"></div>

<!-- prettier-ignore -->
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
</body>
</html>
<!-- [END maps_place_class] -->
52 changes: 52 additions & 0 deletions dist/samples/place-class/app/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// [START maps_place_class]
let map: google.maps.Map;
let centerCoordinates = { lat: 37.4161493, lng: -122.0812166 };

async function initMap() {
const { Map } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;

map = new Map(document.getElementById('map') as HTMLElement, {
center: centerCoordinates,
zoom: 14,
// [START_EXCLUDE]
mapId: '4504f8b37365c3d0',
// [END_EXCLUDE]
});

getPlaceDetails();
}

// [START maps_place_class_fetchfields]
async function getPlaceDetails() {
const { Place } = await google.maps.importLibrary("places") as google.maps.PlacesLibrary;
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;
// Use place ID to create a new Place instance.
const place = new Place({
id: 'ChIJN5Nz71W3j4ARhx5bwpTQEGg',
requestedLanguage: 'en', // optional
});

// Call fetchFields, passing the desired data fields.
await place.fetchFields({ fields: ['displayName', 'formattedAddress', 'location'] });

// Log the result
console.log(place.displayName);
console.log(place.formattedAddress);

// Add an Advanced Marker
const marker = new AdvancedMarkerElement({
map,
position: place.location,
title: place.displayName,
});
}
// [END maps_place_class_fetchfields]

initMap();
// [END maps_place_class]
14 changes: 14 additions & 0 deletions dist/samples/place-class/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@js-api-samples/place-class",
"version": "1.0.0",
"scripts": {
"build": "tsc && bash ../jsfiddle.sh place-class && bash ../app.sh place-class && bash ../docs.sh place-class && npm run build:vite --workspace=. && bash ../dist.sh place-class",
"test": "tsc && npm run build:vite --workspace=.",
"start": "tsc && vite build --base './' && vite",
"build:vite": "vite build --base './'",
"preview": "vite preview"
},
"dependencies": {

}
}
25 changes: 25 additions & 0 deletions dist/samples/place-class/app/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
/* [START maps_place_class] */
/*
* Always set the map height explicitly to define the size of the div element
* that contains the map.
*/
#map {
height: 100%;
}

/*
* Optional: Makes the sample page fill the window.
*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
}

/* [END maps_place_class] */
17 changes: 17 additions & 0 deletions dist/samples/place-class/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"strict": true,
"noImplicitAny": false,
"lib": [
"es2015",
"esnext",
"es6",
"dom",
"dom.iterable"
],
"moduleResolution": "Node",
"jsx": "preserve"
}
}
5 changes: 5 additions & 0 deletions dist/samples/place-class/dist/assets/index-CLgMNE7p.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions dist/samples/place-class/dist/assets/index-DW_Ml_OD.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/#map{height:100%}html,body{height:100%;margin:0;padding:0}
23 changes: 23 additions & 0 deletions dist/samples/place-class/dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<!--
@license
Copyright 2019 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!-- [START maps_place_class] -->
<html>
<head>
<title>Place Class</title>

<script type="module" crossorigin src="./assets/index-CLgMNE7p.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-DW_Ml_OD.css">
</head>
<body>
<div id="map"></div>

<!-- prettier-ignore -->
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
</body>
</html>
<!-- [END maps_place_class] -->
23 changes: 23 additions & 0 deletions dist/samples/place-class/docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<!--
@license
Copyright 2019 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!-- [START maps_place_class] -->
<html>
<head>
<title>Place Class</title>

<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>
</head>
<body>
<div id="map"></div>

<!-- prettier-ignore -->
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
</body>
</html>
<!-- [END maps_place_class] -->
44 changes: 44 additions & 0 deletions dist/samples/place-class/docs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"use strict";
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
// [START maps_place_class]
let map;
let centerCoordinates = { lat: 37.4161493, lng: -122.0812166 };
async function initMap() {
const { Map } = await google.maps.importLibrary("maps");
map = new Map(document.getElementById('map'), {
center: centerCoordinates,
zoom: 14,
// [START_EXCLUDE]
mapId: '4504f8b37365c3d0',
// [END_EXCLUDE]
});
getPlaceDetails();
}
// [START maps_place_class_fetchfields]
async function getPlaceDetails() {
const { Place } = await google.maps.importLibrary("places");
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker");
// Use place ID to create a new Place instance.
const place = new Place({
id: 'ChIJN5Nz71W3j4ARhx5bwpTQEGg',
requestedLanguage: 'en', // optional
});
// Call fetchFields, passing the desired data fields.
await place.fetchFields({ fields: ['displayName', 'formattedAddress', 'location'] });
// Log the result
console.log(place.displayName);
console.log(place.formattedAddress);
// Add an Advanced Marker
const marker = new AdvancedMarkerElement({
map,
position: place.location,
title: place.displayName,
});
}
// [END maps_place_class_fetchfields]
initMap();
// [END maps_place_class]
52 changes: 52 additions & 0 deletions dist/samples/place-class/docs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// [START maps_place_class]
let map: google.maps.Map;
let centerCoordinates = { lat: 37.4161493, lng: -122.0812166 };

async function initMap() {
const { Map } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;

map = new Map(document.getElementById('map') as HTMLElement, {
center: centerCoordinates,
zoom: 14,
// [START_EXCLUDE]
mapId: '4504f8b37365c3d0',
// [END_EXCLUDE]
});

getPlaceDetails();
}

// [START maps_place_class_fetchfields]
async function getPlaceDetails() {
const { Place } = await google.maps.importLibrary("places") as google.maps.PlacesLibrary;
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;
// Use place ID to create a new Place instance.
const place = new Place({
id: 'ChIJN5Nz71W3j4ARhx5bwpTQEGg',
requestedLanguage: 'en', // optional
});

// Call fetchFields, passing the desired data fields.
await place.fetchFields({ fields: ['displayName', 'formattedAddress', 'location'] });

// Log the result
console.log(place.displayName);
console.log(place.formattedAddress);

// Add an Advanced Marker
const marker = new AdvancedMarkerElement({
map,
position: place.location,
title: place.displayName,
});
}
// [END maps_place_class_fetchfields]

initMap();
// [END maps_place_class]
25 changes: 25 additions & 0 deletions dist/samples/place-class/docs/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
/* [START maps_place_class] */
/*
* Always set the map height explicitly to define the size of the div element
* that contains the map.
*/
#map {
height: 100%;
}

/*
* Optional: Makes the sample page fill the window.
*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
}

/* [END maps_place_class] */
Loading