Skip to content

Commit eb29934

Browse files
Update dist folder [skip ci] (#662)
1 parent de71a2d commit eb29934

File tree

21 files changed

+650
-0
lines changed

21 files changed

+650
-0
lines changed

‎dist/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ <h1>Maps JSAPI Samples</h1>
4949
<li><a href='/samples/deckgl-polygon/dist'>deckgl-polygon</a></li>
5050
<li><a href='/samples/map-drawing-terradraw/dist'>map-drawing-terradraw</a></li>
5151
<li><a href='/samples/map-simple/dist'>map-simple</a></li>
52+
<li><a href='/samples/place-autocomplete-basic-map/dist'>place-autocomplete-basic-map</a></li>
5253
<li><a href='/samples/place-autocomplete-data-session/dist'>place-autocomplete-data-session</a></li>
5354
<li><a href='/samples/place-autocomplete-element/dist'>place-autocomplete-element</a></li>
5455
<li><a href='/samples/place-autocomplete-map/dist'>place-autocomplete-map</a></li>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": [
3+
"plugin:@typescript-eslint/recommended"
4+
],
5+
"parser": "@typescript-eslint/parser",
6+
"rules": {
7+
"@typescript-eslint/ban-ts-comment": 0,
8+
"@typescript-eslint/no-this-alias": 1,
9+
"@typescript-eslint/no-empty-function": 1,
10+
"@typescript-eslint/explicit-module-boundary-types": 1,
11+
"@typescript-eslint/no-unused-vars": 1
12+
}
13+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Google Maps JavaScript Sample
2+
3+
This sample is generated from @googlemaps/js-samples located at
4+
https://github.com/googlemaps-samples/js-api-samples.
5+
6+
## Setup
7+
8+
### Before starting run:
9+
10+
`npm i`
11+
12+
### Run an example on a local web server
13+
14+
First `cd` to the folder for the sample to run, then:
15+
16+
`npm start`
17+
18+
### Build an individual example
19+
20+
From `samples/`:
21+
22+
`npm run build --workspace=sample-name/`
23+
24+
### Build all of the examples.
25+
26+
From `samples/`:
27+
28+
`npm run build-all`
29+
30+
## Feedback
31+
32+
For feedback related to this sample, please open a new issue on
33+
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!doctype html>
2+
<!--
3+
@license
4+
Copyright 2025 Google LLC. All Rights Reserved.
5+
SPDX-License-Identifier: Apache-2.0
6+
-->
7+
<!-- [START maps_place_autocomplete_basic_map] -->
8+
<html>
9+
<head>
10+
<title>Place Autocomplete map</title>
11+
12+
<link rel="stylesheet" type="text/css" href="./style.css" />
13+
<script type="module" src="./index.js"></script>
14+
</head>
15+
<body>
16+
<div id="map-container">
17+
<gmp-basic-place-autocomplete></gmp-basic-place-autocomplete>
18+
<gmp-place-details-compact orientation="horizontal">
19+
<gmp-place-details-place-request></gmp-place-details-place-request>
20+
<gmp-place-all-content></gmp-place-all-content>
21+
</gmp-place-details-compact>
22+
<gmp-map zoom="14" map-id="DEMO_MAP_ID">
23+
<gmp-advanced-marker></gmp-advanced-marker>
24+
</gmp-map>
25+
</div>
26+
27+
<!-- prettier-ignore -->
28+
<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))})
29+
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
30+
</body>
31+
</html>
32+
<!-- [END maps_place_autocomplete_basic_map] -->
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* @license
3+
* Copyright 2025 Google LLC. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
8+
// [START maps_place_autocomplete_basic_map]
9+
const mapContainer = document.getElementById("map-container") as any;
10+
const autocompleteElement = document.querySelector('gmp-basic-place-autocomplete') as any;
11+
const detailsElement = document.querySelector('gmp-place-details-compact') as any;
12+
const mapElement = document.querySelector('gmp-map') as any;
13+
const advancedMarkerElement = document.querySelector('gmp-advanced-marker') as any;
14+
15+
let center = { lat: 40.749933, lng: -73.98633 }; // New York City
16+
17+
async function initMap(): Promise<void>{
18+
//@ts-ignore
19+
const {BasicPlaceAutocompleteElement, PlaceDetailsElement} = await google.maps.importLibrary('places');
20+
//@ts-ignore
21+
const {AdvancedMarkerElement} = await google.maps.importLibrary('marker');
22+
//@ts-ignore
23+
const {LatLngBounds} = await google.maps.importLibrary('core');
24+
25+
// Set the initial map location and autocomplete location bias
26+
mapElement.center = center
27+
autocompleteElement.locationBias = center;
28+
29+
// Get the underlying google.maps.Map object to add listeners
30+
const map = mapElement.innerMap;
31+
32+
// Add the listener tochange locationBias to locationRestriction when the map moves
33+
map.addListener('bounds_changed', () => {
34+
autocompleteElement.locationBias = null;
35+
autocompleteElement.locationRestriction = map.getBounds();
36+
console.log("bias changed to restriction")
37+
});
38+
39+
// [START maps_place_autocomplete_basic_map_listener]
40+
// Add the listener to update the Place Request element when the user selects a prediction
41+
autocompleteElement.addEventListener('gmp-select', async (event) => {
42+
const placeDetailsRequest = document.querySelector('gmp-place-details-place-request') as any;
43+
placeDetailsRequest.place = event.place.id;
44+
});
45+
// [END maps_place_autocomplete_basic_map_listener]
46+
47+
// Add the listener to update the marker when the Details element loads
48+
detailsElement.addEventListener('gmp-load', async () => {
49+
const location = detailsElement.place.location;
50+
detailsElement.style.display = "block"
51+
advancedMarkerElement.position = location;
52+
advancedMarkerElement.content = detailsElement;
53+
if (detailsElement.place.viewport) {
54+
map.fitBounds(detailsElement.place.viewport);
55+
} else {
56+
map.setCenter(location);
57+
map.setZoom(17);
58+
}
59+
});
60+
}
61+
62+
initMap();
63+
// [END maps_place_autocomplete_basic_map]
64+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@js-api-samples/place-autocomplete-basic-map",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"build": "tsc && bash ../jsfiddle.sh place-autocomplete-basic-map && bash ../app.sh place-autocomplete-basic-map && bash ../docs.sh place-autocomplete-basic-map && npm run build:vite --workspace=. && bash ../dist.sh place-autocomplete-basic-map",
6+
"test": "tsc && npm run build:vite --workspace=.",
7+
"start": "tsc && vite build --base './' && vite",
8+
"build:vite": "vite build --base './'",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
13+
}
14+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
/* [START maps_place_autocomplete_basic_map] */
7+
html,
8+
body {
9+
height: 100%;
10+
margin: 0;
11+
padding: 0;
12+
}
13+
14+
#map-container {
15+
display: flex;
16+
flex-direction: row;
17+
height: 100%;
18+
}
19+
20+
#gmp-map {
21+
height: 100%;
22+
}
23+
24+
gmp-basic-place-autocomplete {
25+
position: absolute;
26+
height: 50px;
27+
top: 10px;
28+
left: 10px;
29+
z-index: 1;
30+
box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.2);
31+
color-scheme: light;
32+
border-radius: 10px;
33+
}
34+
35+
gmp-place-details-compact {
36+
width: 360px;
37+
max-height: 300px;
38+
border: none;
39+
padding: 0;
40+
margin: 0;
41+
position: absolute;
42+
transform: translate(calc(-180px), calc(-215px));
43+
box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.2);
44+
color-scheme: light;
45+
}
46+
47+
/* This creates the pointer attached to the bottom of the element. */
48+
gmp-place-details-compact::after {
49+
content: "";
50+
position: absolute;
51+
top: 100%;
52+
left: 50%;
53+
transform: translateX(-50%);
54+
width: 0;
55+
height: 0;
56+
border-left: 16px solid transparent;
57+
border-right: 16px solid transparent;
58+
border-top: 20px solid var(--gmp-mat-color-surface, light-dark(white, black));
59+
}
60+
/* [END maps_place_autocomplete_basic_map] */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"module": "esnext",
4+
"target": "esnext",
5+
"strict": true,
6+
"noImplicitAny": false,
7+
"lib": [
8+
"es2015",
9+
"esnext",
10+
"es6",
11+
"dom",
12+
"dom.iterable"
13+
],
14+
"moduleResolution": "Node",
15+
"jsx": "preserve"
16+
}
17+
}

‎dist/samples/place-autocomplete-basic-map/dist/assets/index-BmNok-li.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/samples/place-autocomplete-basic-map/dist/assets/index-D9sGUCsY.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)