77// [START maps_advanced_markers_basic_style]
88const parser = new DOMParser ( ) ;
99const mapElement = document . querySelector ( 'gmp-map' ) as google . maps . MapElement ;
10- let innerMap ;
1110
1211async function initMap ( ) {
1312 // Request needed libraries.
1413 const { Map } = await google . maps . importLibrary ( "maps" ) as google . maps . MapsLibrary ;
1514 const { AdvancedMarkerElement, PinElement } = await google . maps . importLibrary ( "marker" ) as google . maps . MarkerLibrary ;
1615
17- innerMap = mapElement . innerMap ;
18-
1916 // Each PinElement is paired with a MarkerView to demonstrate setting each parameter.
2017
2118 // [START maps_advanced_markers_basic_style_title]
2219 // Default marker with title text (no PinElement).
2320 const markerViewWithText = new AdvancedMarkerElement ( {
24- map : innerMap ,
2521 position : { lat : 37.419 , lng : - 122.03 } ,
2622 title : 'Title text for the marker at lat: 37.419, lng: -122.03' ,
2723 } ) ;
24+ mapElement . append ( markerViewWithText ) ;
2825 // [END maps_advanced_markers_basic_style_title]
2926
3027 // [START maps_advanced_markers_basic_style_scale]
@@ -33,10 +30,10 @@ async function initMap() {
3330 scale : 1.5 ,
3431 } ) ;
3532 const markerViewScaled = new AdvancedMarkerElement ( {
36- map : innerMap ,
3733 position : { lat : 37.419 , lng : - 122.02 } ,
3834 content : pinScaled . element ,
3935 } ) ;
36+ mapElement . append ( markerViewScaled ) ;
4037 // [END maps_advanced_markers_basic_style_scale]
4138
4239 // [START maps_advanced_markers_basic_style_background]
@@ -45,10 +42,10 @@ async function initMap() {
4542 background : '#FBBC04' ,
4643 } ) ;
4744 const markerViewBackground = new AdvancedMarkerElement ( {
48- map : innerMap ,
4945 position : { lat : 37.419 , lng : - 122.01 } ,
5046 content : pinBackground . element ,
5147 } ) ;
48+ mapElement . append ( markerViewBackground ) ;
5249 // [END maps_advanced_markers_basic_style_background]
5350
5451 // [START maps_advanced_markers_basic_style_border]
@@ -57,10 +54,10 @@ async function initMap() {
5754 borderColor : '#137333' ,
5855 } ) ;
5956 const markerViewBorder = new AdvancedMarkerElement ( {
60- map : innerMap ,
6157 position : { lat : 37.415 , lng : - 122.035 } ,
6258 content : pinBorder . element ,
6359 } ) ;
60+ mapElement . append ( markerViewBorder ) ;
6461 // [END maps_advanced_markers_basic_style_border]
6562
6663 // [START maps_advanced_markers_basic_style_glyph]
@@ -69,34 +66,36 @@ async function initMap() {
6966 glyphColor : 'white' ,
7067 } ) ;
7168 const markerViewGlyph = new AdvancedMarkerElement ( {
72- map : innerMap ,
7369 position : { lat : 37.415 , lng : - 122.025 } ,
7470 content : pinGlyph . element ,
7571 } ) ;
72+ mapElement . append ( markerViewGlyph ) ;
7673 // [END maps_advanced_markers_basic_style_glyph]
7774
7875 // [START maps_advanced_markers_basic_style_text_glyph]
7976 const pinTextGlyph = new PinElement ( {
80- glyph : 'T' ,
77+ //@ts -ignore
78+ glyphText : 'T' ,
8179 glyphColor : 'white' ,
8280 } ) ;
8381 const markerViewGlyphText = new AdvancedMarkerElement ( {
84- map : innerMap ,
8582 position : { lat : 37.415 , lng : - 122.015 } ,
8683 content : pinTextGlyph . element ,
8784 } ) ;
85+ mapElement . append ( markerViewGlyphText ) ;
8886 // [END maps_advanced_markers_basic_style_text_glyph]
8987
9088 // [START maps_advanced_markers_basic_style_hide_glyph]
9189 // Hide the glyph.
9290 const pinNoGlyph = new PinElement ( {
93- glyph : '' ,
91+ //@ts -ignore
92+ glyphText : '' ,
9493 } ) ;
9594 const markerViewNoGlyph = new AdvancedMarkerElement ( {
96- map : innerMap ,
9795 position : { lat : 37.415 , lng : - 122.005 } ,
9896 content : pinNoGlyph . element ,
9997 } ) ;
98+ mapElement . append ( markerViewNoGlyph ) ;
10099 // [END maps_advanced_markers_basic_style_hide_glyph]
101100
102101}
0 commit comments