Pin

Storybook

Open the Pin story

Pin customises the default Advanced Marker pin with a google.maps.marker.PinElement. Use it as a child of AdvancedMarker.

Props

PropTypeDefaultDescription
backgroundstringPin background color.
borderColorstringPin border color.
glyphColorstringColor of the glyph (the circle or text in the middle).
glyphTextstringText shown inside the pin.
glyphSrcstring | URLImage URL shown inside the pin.
scalenumberPin size multiplier.

All props are reactive and update the pin in place.

Usage

<script lang="ts">
	import { APIProvider, GoogleMap, AdvancedMarker, Pin } from 'svelte-google-maps-api';
</script>

<div style="height: 400px;">
	<APIProvider apiKey="YOUR_API_KEY">
		<GoogleMap center={{ lat: 35.6812, lng: 139.7671 }} zoom={13} mapId="DEMO_MAP_ID">
			<AdvancedMarker position={{ lat: 35.6812, lng: 139.7671 }}>
				<Pin background="#2563eb" borderColor="#1e3a8a" glyphColor="white" glyphText="A" scale={1.2} />
			</AdvancedMarker>
		</GoogleMap>
	</APIProvider>
</div>
svelte

Notes

  • Pin must be a direct or nested child of AdvancedMarker; it throws otherwise.
  • Like every Advanced Marker, it needs a map with a mapId.
  • glyphText and glyphSrc replace the deprecated glyph option of PinElement.