Skip to content

Commit 24e970f

Browse files
authored
Refactor marker initialization in initMap function
Updated the marker initialization to append directly to the map element instead of using innerMap.
1 parent 7de6155 commit 24e970f

File tree

1 file changed

+1
-7
lines changed
  • samples/advanced-markers-html-simple

1 file changed

+1
-7
lines changed

samples/advanced-markers-html-simple/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// [START maps_advanced_markers_html_simple]
88
// [START maps_advanced_markers_html_simple_snippet]
99
const mapElement = document.querySelector("gmp-map") as google.maps.MapElement;
10-
let innerMap;
1110

1211
async function initMap() {
1312
// Request needed libraries.
@@ -18,20 +17,15 @@ async function initMap() {
1817
"marker"
1918
)) as google.maps.MarkerLibrary;
2019

21-
innerMap = mapElement.innerMap;
22-
innerMap.setOptions({
23-
mapTypeControl: false,
24-
});
25-
2620
const priceTag = document.createElement("div");
2721
priceTag.className = "price-tag";
2822
priceTag.textContent = "$2.5M";
2923

3024
const marker = new AdvancedMarkerElement({
31-
map: innerMap,
3225
position: { lat: 37.42, lng: -122.1 },
3326
content: priceTag,
3427
});
28+
mapElement.append(marker);
3529
}
3630
// [END maps_advanced_markers_html_simple_snippet]
3731
initMap();

0 commit comments

Comments
 (0)