@@ -15,6 +15,10 @@ async function initMap() {
1515 ) ) as google . maps . MapsLibrary ;
1616
1717 innerMap = mapElement . innerMap ;
18+ innerMap . setOptions ( {
19+ mapTypeControl : false
20+ } ) ;
21+
1822 infoWindow = new InfoWindow ( ) ;
1923 getPlaceDetails ( ) ;
2024}
@@ -58,19 +62,42 @@ async function getPlaceDetails() {
5862 const address = document . createElement ( 'div' ) ;
5963 const summary = document . createElement ( 'div' ) ;
6064 const lineBreak = document . createElement ( 'br' ) ;
65+ const attribution = document . createElement ( 'div' ) ;
6166
62- // Retrieve the summary text and disclosure text .
67+ // Retrieve the textual data (summary, disclosure, flag URI) .
6368 //@ts -ignore
6469 let overviewText = place . generativeSummary . overview ?? 'No summary is available.' ;
6570 //@ts -ignore
66- let disclosureText = place . generativeSummary . disclosureText ?? '' ;
71+ let disclosureText = place . generativeSummary . disclosureText ;
72+ //@ts -ignore
73+ let reportingUri = place . generativeSummary . flagContentURI ;
6774
75+ // Create HTML for reporting link.
76+ const reportingLink = document . createElement ( 'a' ) ;
77+ reportingLink . href = reportingUri ;
78+ reportingLink . target = '_blank' ;
79+ reportingLink . textContent = "Report a problem."
80+
81+ // Add text to layout.
6882 address . textContent = place . formattedAddress ?? '' ;
69- summary . textContent = `${ overviewText } [${ disclosureText } ]` ;
70- content . append ( address , lineBreak , summary ) ; ;
83+ summary . textContent = overviewText ;
84+ attribution . textContent = `${ disclosureText } ` ;
85+ attribution . appendChild ( reportingLink ) ;
86+
87+ content . append ( address , lineBreak , summary , lineBreak , attribution ) ;
7188
7289 innerMap . setCenter ( place . location ) ;
7390
91+ // Handle marker click.
92+ marker . addListener ( 'gmp-click' , ( ) => {
93+ showInfoWindow ( marker , place , content ) ;
94+ } ) ;
95+
96+ // Display the info window at load time.
97+ showInfoWindow ( marker , place , content ) ;
98+ }
99+
100+ function showInfoWindow ( marker , place , content ) {
74101 // Display an info window.
75102 infoWindow . setHeaderContent ( place . displayName ) ;
76103 infoWindow . setContent ( content ) ;
0 commit comments