Skip to content

Commit cb90d4e

Browse files
authored
feat: Updates sample to use marker anchor option. (#820)
* feat: Updates sample to use marker anchor option. Change-Id: Id685454421924fa708f2478d8edc58132f2500e5 * Change Google Maps API version from alpha to weekly * Remove unnecessary newline in index.ts * Remove newline * Remove ts-ignore for custom marker definition Removed TypeScript ignore directive for better type safety. * Remove TypeScript ignore comment for marker * Adds ts-ignores to anchorLeft and anchorTop lines. The ts-ignores were added because we don't have typings yet.
1 parent 58435ac commit cb90d4e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

samples/advanced-markers-graphics/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<!-- prettier-ignore -->
2121
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
22-
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "beta"});</script>
22+
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
2323
</body>
2424
</html>
2525
<!-- [END maps_advanced_markers_graphics] -->

samples/advanced-markers-graphics/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ async function initMap() {
2525

2626
const pinSvg =
2727
parser.parseFromString(pinSvgString, 'image/svg+xml').documentElement;
28-
2928
const pinSvgMarkerView = new AdvancedMarkerElement({
3029
map,
3130
position: { lat: 37.42475, lng: -122.094 },
3231
content: pinSvg,
3332
title: 'A marker using a custom SVG image.',
33+
//@ts-ignore
34+
anchorLeft: "-50%",
35+
anchorTop: "-50%",
3436
});
3537
// [END maps_advanced_markers_graphics_inline]
3638

@@ -44,6 +46,9 @@ async function initMap() {
4446
position: { lat: 37.434, lng: -122.082 },
4547
content: beachFlagImg,
4648
title: 'A marker using a custom PNG Image',
49+
//@ts-ignore
50+
anchorLeft: "0px",
51+
anchorTop: "100%",
4752
});
4853
// [END maps_advanced_markers_graphics_png]
4954

@@ -84,7 +89,6 @@ async function initMap() {
8489
content: pinElement.element,
8590
title: place.displayName,
8691
});
87-
8892
// [END maps_advanced_markers_graphics_place_icon]
8993

9094
// [START maps_advanced_markers_graphics_fontawesome]
@@ -108,4 +112,4 @@ async function initMap() {
108112
}
109113

110114
initMap();
111-
// [END maps_advanced_markers_graphics]
115+
// [END maps_advanced_markers_graphics]

0 commit comments

Comments
 (0)