Skip to content

Commit dcc9109

Browse files
committed
feat: Adds UI Kit place details and place search examples.
1 parent db3bf9d commit dcc9109

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

samples/ui-kit-place-details/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
</head>
1515
<body>
1616
<h1>Click on the map to view place details</h1>
17+
<!--[START maps_ui_kit_place_details_map] -->
1718
<gmp-map center="-37.813,144.963" zoom="2" map-id="DEMO_MAP_ID" style="height: 400px">
1819
<gmp-place-details
1920
size="x-large"
2021
slot="control-inline-start-block-start"></gmp-place-details>
2122
<gmp-advanced-marker></gmp-advanced-marker>
2223
</gmp-map>
24+
<!--[END maps_ui_kit_place_details_map] -->
2325
<script
2426
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8&libraries=maps&callback=initMap&v=alpha"
2527
defer

samples/ui-kit-place-details/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*/
66
/* [START maps_ui_kit_place_details] */
77
// Use querySelector to select elements for interaction.
8+
/* [START maps_ui_kit_place_details_query_selector] */
89
const map = document.querySelector('gmp-map') as any;
910
const placeDetails = document.querySelector('gmp-place-details') as any;
1011
const marker = document.querySelector('gmp-advanced-marker') as any;
12+
/* [END maps_ui_kit_place_details_query_selector] */
1113

1214
async function initMap(): Promise<void> {
1315
// Request needed libraries.
@@ -22,6 +24,7 @@ async function initMap(): Promise<void> {
2224
// Hide the map type control.
2325
map.innerMap.setOptions({mapTypeControl: false});
2426

27+
/* [START maps_ui_kit_place_details_event] */
2528
// Add an event listener to handle map clicks.
2629
map.innerMap.addListener('click', async (event) => {
2730
marker.position = null;
@@ -39,6 +42,7 @@ async function initMap(): Promise<void> {
3942
marker.style.display = 'block';
4043
});
4144
}
45+
/* [END maps_ui_kit_place_details_event] */
4246

4347
// Helper function for geolocation.
4448
async function findCurrentLocation() {

samples/ui-kit-place-search/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
</head>
1515
<body>
1616
<h1>Place List Nearby Search with Google Maps</h1>
17+
<!--[START maps_ui_kit_place_search_map] -->
1718
<gmp-map center="-37.813,144.963" zoom="10" map-id="DEMO_MAP_ID">
1819
<div class="overlay" slot="control-inline-start-block-start">
1920
<div class="controls">
@@ -32,6 +33,7 @@ <h1>Place List Nearby Search with Google Maps</h1>
3233
</div>
3334
<gmp-place-details size="large"></gmp-place-details>
3435
</gmp-map>
36+
<!--[END maps_ui_kit_place_search_map] -->
3537
<script
3638
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8&libraries=maps&callback=initMap&v=alpha"
3739
defer

samples/ui-kit-place-search/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
/* [START maps_ui_kit_place_search] */
7+
/* [START maps_ui_kit_place_search_query_selectors] */
78
const map = document.querySelector("gmp-map") as any;
89
const placeList = document.querySelector("gmp-place-list") as any;
910
const typeSelect = document.querySelector(".type-select") as any;
10-
const searchButton = document.querySelector(".search-button") as any;
1111
const placeDetails = document.querySelector("gmp-place-details") as any;
1212
let marker = document.querySelector('gmp-advanced-marker') as any;
13-
let infowindow;
13+
/* [END maps_ui_kit_place_search_query_selectors] */
1414
let markers = {};
15+
let infowindow;
1516
let mapCenter;
1617

1718
async function initMap(): Promise<void> {
@@ -36,7 +37,7 @@ async function initMap(): Promise<void> {
3637
clickableIcons: false,
3738
});
3839

39-
//searchButton.addEventListener("click", () => {
40+
/* [START maps_ui_kit_place_search_event] */
4041
typeSelect.addEventListener("change", (event) => {
4142
// First remove all existing markers.
4243
for(marker in markers){
@@ -58,6 +59,7 @@ async function initMap(): Promise<void> {
5859
});
5960
}
6061
});
62+
/* [END maps_ui_kit_place_search_event] */
6163
}
6264

6365
async function addMarkers(){

0 commit comments

Comments
 (0)