File tree Expand file tree Collapse file tree 4 files changed +13
-3
lines changed
Expand file tree Collapse file tree 4 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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] */
89const map = document . querySelector ( 'gmp-map' ) as any ;
910const placeDetails = document . querySelector ( 'gmp-place-details' ) as any ;
1011const marker = document . querySelector ( 'gmp-advanced-marker' ) as any ;
12+ /* [END maps_ui_kit_place_details_query_selector] */
1113
1214async 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.
4448async function findCurrentLocation ( ) {
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 44 * SPDX-License-Identifier: Apache-2.0
55 */
66/* [START maps_ui_kit_place_search] */
7+ /* [START maps_ui_kit_place_search_query_selectors] */
78const map = document . querySelector ( "gmp-map" ) as any ;
89const placeList = document . querySelector ( "gmp-place-list" ) as any ;
910const typeSelect = document . querySelector ( ".type-select" ) as any ;
10- const searchButton = document . querySelector ( ".search-button" ) as any ;
1111const placeDetails = document . querySelector ( "gmp-place-details" ) as any ;
1212let marker = document . querySelector ( 'gmp-advanced-marker' ) as any ;
13- let infowindow ;
13+ /* [END maps_ui_kit_place_search_query_selectors] */
1414let markers = { } ;
15+ let infowindow ;
1516let mapCenter ;
1617
1718async 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
6365async function addMarkers ( ) {
You can’t perform that action at this time.
0 commit comments