npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

svelte-google-maps-api

v0.2.3

Published

A Svelte component library for integrating Google Maps JavaScript API into Svelte applications

Readme

Svelte Google Maps API

A declarative Svelte component library for the Google Maps JavaScript API.

Installation

pnpm add svelte-google-maps-api
npm install svelte-google-maps-api
yarn add svelte-google-maps-api

Quick Start

Enable the Maps JavaScript API in Google Cloud Console and pass your API key to APIProvider.

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

	const apiKey = 'YOUR_MAP_KEY';
</script>

<div style="width: 100%; height: 100vh;">
	<APIProvider {apiKey}>
		<GoogleMap
			options={{
				center: { lat: 35.6812362, lng: 139.7649361 },
				zoom: 14
			}}
			mapContainerStyle="width:100%;height:100%;"
		>
			<Marker position={{ lat: 35.6812362, lng: 139.7649361 }} />
		</GoogleMap>
	</APIProvider>
</div>

Loading Google Maps Libraries

Some components require optional Google Maps libraries. Pass them through APIProvider.

<APIProvider {apiKey} libraries={['marker', 'places', 'drawing', 'visualization']}>
	<!-- map components -->
</APIProvider>

| Component | Required library | Notes | | --------------------- | ---------------- | --------------------------------------------------------------------------------------------------------- | | AdvancedMarker | marker | Advanced markers may require a map ID for full styling and cloud-based map features. | | Autocomplete | places | Wraps google.maps.places.Autocomplete. | | StandaloneSearchBox | places | Wraps google.maps.places.SearchBox. | | DrawingManager | drawing | The Google Maps Drawing Library is deprecated upstream; use a supported Maps API version while available. | | HeatmapLayer | visualization | Wraps google.maps.visualization.HeatmapLayer. |

Components

| Component | Purpose | | --------------------------------------------------------------------------------------------- | ------------------------------------------------------- | | APIProvider | Loads the Maps JavaScript API and provides context. | | GoogleMap | Creates and provides a map instance. | | Marker | Standard Google Maps marker. | | AdvancedMarker | Advanced marker element with slot content support. | | MarkerClusterer | Marker clustering wrapper with onClick compatibility. | | GoogleMarkerClusterer | Marker clustering wrapper exposing onClusterClick. | | InfoWindow | Google Maps info window. | | InfoBox | Custom overlay info box. | | Polyline, Polygon, Circle, Rectangle | Shape overlays. | | Data | Google Maps data layer. | | DrawingManager | Drawing tools where the upstream library is available. | | DirectionsRenderer, DirectionsService, DistanceMatrixService | Directions and distance services. | | HeatmapLayer, KmlLayer, TrafficLayer, TransitLayer, BicyclingLayer, GroundOverlay | Map layers and image overlays. | | MapControl | Custom control placement. | | Autocomplete, StandaloneSearchBox | Places input helpers. | | OverlayView | Custom positioned overlay content. | | StreetViewPanorama, StreetViewService | Street View UI and service helpers. |

SvelteKit and SSR

Render map components only in the browser. APIProvider loads the Google Maps script on the client, and child components wait for that context before creating Google Maps objects.

For SvelteKit routes that render on the server, keep API keys in public environment variables only when they are meant to be exposed to browsers:

<script lang="ts">
	import { PUBLIC_GOOGLE_MAPS_API_KEY } from '$env/static/public';
	import { APIProvider, GoogleMap } from 'svelte-google-maps-api';
</script>

<APIProvider apiKey={PUBLIC_GOOGLE_MAPS_API_KEY}>
	<GoogleMap options={{ center: { lat: 35.6812362, lng: 139.7649361 }, zoom: 12 }} />
</APIProvider>

Restrict browser API keys in Google Cloud Console by HTTP referrer and only enable the APIs needed by your app.

Troubleshooting

| Symptom | Check | | -------------------------------- | ---------------------------------------------------------------------------------------------------- | | The map does not render | Confirm the Maps JavaScript API is enabled and the API key is allowed for your domain. | | AdvancedMarker does not render | Add libraries={['marker']} and configure a map ID when using cloud-styled maps. | | Places components do not work | Add libraries={['places']} and enable the Places API. | | HeatmapLayer is unavailable | Add libraries={['visualization']}. | | DrawingManager is unavailable | The upstream Drawing Library is deprecated; pin a supported API version where it is still available. | | Storybook asks for an API key | Enter a restricted browser key in the Storybook API key field for local visual testing. |

Documentation

  • Docs: https://skyt-a.github.io/svelte-google-maps-api/
  • Storybook: https://skyt-a.github.io/svelte-google-maps-api/storybook/
  • Repository: https://github.com/skyt-a/svelte-google-maps-api

License

MIT