Skip to content

Commit 2f2e422

Browse files
authored
Refactor marker creation and usage in index.ts
1 parent 0a8706e commit 2f2e422

File tree

1 file changed

+21
-21
lines changed
  • samples/advanced-markers-basic-style

1 file changed

+21
-21
lines changed

samples/advanced-markers-basic-style/index.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,63 +13,63 @@ async function initMap() {
1313
const { Map } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
1414
const { AdvancedMarkerElement, PinElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;
1515

16-
// Each PinElement is paired with a MarkerView to demonstrate setting each parameter.
16+
// Each PinElement is paired with a marker to demonstrate setting each parameter.
1717

1818
// [START maps_advanced_markers_basic_style_title]
1919
// Default marker with title text (no PinElement).
20-
const markerViewWithText = new AdvancedMarkerElement({
20+
const markerWithText = new AdvancedMarkerElement({
2121
position: { lat: 37.419, lng: -122.03 },
2222
title: 'Title text for the marker at lat: 37.419, lng: -122.03',
2323
});
24-
mapElement.append(markerViewWithText);
24+
mapElement.append(markerWithText);
2525
// [END maps_advanced_markers_basic_style_title]
2626

2727
// [START maps_advanced_markers_basic_style_scale]
2828
// Adjust the scale.
2929
const pinScaled = new PinElement({
3030
scale: 1.5,
3131
});
32-
const markerViewScaled = new AdvancedMarkerElement({
32+
const markerScaled = new AdvancedMarkerElement({
3333
position: { lat: 37.419, lng: -122.02 },
34-
content: pinScaled.element,
3534
});
36-
mapElement.append(markerViewScaled);
35+
markerScaled.append(pinScaled);
36+
mapElement.append(markerScaled);
3737
// [END maps_advanced_markers_basic_style_scale]
3838

3939
// [START maps_advanced_markers_basic_style_background]
4040
// Change the background color.
4141
const pinBackground = new PinElement({
4242
background: '#FBBC04',
4343
});
44-
const markerViewBackground = new AdvancedMarkerElement({
44+
const markerBackground = new AdvancedMarkerElement({
4545
position: { lat: 37.419, lng: -122.01 },
46-
content: pinBackground.element,
4746
});
48-
mapElement.append(markerViewBackground);
47+
markerBackground.append(pinBackground);
48+
mapElement.append(markerBackground);
4949
// [END maps_advanced_markers_basic_style_background]
5050

5151
// [START maps_advanced_markers_basic_style_border]
5252
// Change the border color.
5353
const pinBorder = new PinElement({
5454
borderColor: '#137333',
5555
});
56-
const markerViewBorder = new AdvancedMarkerElement({
56+
const markerBorder = new AdvancedMarkerElement({
5757
position: { lat: 37.415, lng: -122.035 },
58-
content: pinBorder.element,
5958
});
60-
mapElement.append(markerViewBorder);
59+
markerBorder.append(pinBorder);
60+
mapElement.append(markerBorder);
6161
// [END maps_advanced_markers_basic_style_border]
6262

6363
// [START maps_advanced_markers_basic_style_glyph]
6464
// Change the glyph color.
6565
const pinGlyph = new PinElement({
6666
glyphColor: 'white',
6767
});
68-
const markerViewGlyph = new AdvancedMarkerElement({
68+
const markerGlyph = new AdvancedMarkerElement({
6969
position: { lat: 37.415, lng: -122.025 },
70-
content: pinGlyph.element,
7170
});
72-
mapElement.append(markerViewGlyph);
71+
markerGlyph.append(pinGlyph);
72+
mapElement.append(markerGlyph);
7373
// [END maps_advanced_markers_basic_style_glyph]
7474

7575
// [START maps_advanced_markers_basic_style_text_glyph]
@@ -78,11 +78,11 @@ async function initMap() {
7878
glyphText: 'T',
7979
glyphColor: 'white',
8080
});
81-
const markerViewGlyphText = new AdvancedMarkerElement({
81+
const markerGlyphText = new AdvancedMarkerElement({
8282
position: { lat: 37.415, lng: -122.015 },
83-
content: pinTextGlyph.element,
8483
});
85-
mapElement.append(markerViewGlyphText);
84+
markerGlyphText.append(pinTextGlyph);
85+
mapElement.append(markerGlyphText);
8686
// [END maps_advanced_markers_basic_style_text_glyph]
8787

8888
// [START maps_advanced_markers_basic_style_hide_glyph]
@@ -91,11 +91,11 @@ async function initMap() {
9191
//@ts-ignore
9292
glyphText: '',
9393
});
94-
const markerViewNoGlyph = new AdvancedMarkerElement({
94+
const markerNoGlyph = new AdvancedMarkerElement({
9595
position: { lat: 37.415, lng: -122.005 },
96-
content: pinNoGlyph.element,
9796
});
98-
mapElement.append(markerViewNoGlyph);
97+
markerNoGlyph.append(pinNoGlyph);
98+
mapElement.append(markerNoGlyph);
9999
// [END maps_advanced_markers_basic_style_hide_glyph]
100100

101101
}

0 commit comments

Comments
 (0)