New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

solid-google-maps

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solid-google-maps

SolidJS components and hooks for the Google Maps Javascript API

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-91.34%
Maintainers
0
Weekly downloads
 
Created
Source

Solid Google Maps solid-google-maps minzip package size solid-google-maps package version

Solid Google Maps provides a loader and simple reactive bindings for the Google Maps API

Demo and examples: https://solid-google-maps.vercel.app/

Install

pnpm install solid-google-maps

Map

import { APIProvider, Map } from 'solid-google-maps'

const BasicExample = () => {
  return (
    <APIProvider apiKey={API_KEY}>
      <Map
        style={{ height: '500px', width: '100%' }}
        defaultZoom={3}
        defaultCenter={{ lat: 22.54992, lng: 0 }}
        gestureHandling={'greedy'}
        disableDefaultUI={true}
      />
    </APIProvider>
  )
}

Advanced Marker

import { APIProvider, Map } from 'solid-google-maps'

const MarkerExample = () => {
  return (
    <APIProvider apiKey={API_KEY}>
      <Map
        style={{ height: '500px', width: '100%' }}
        defaultZoom={3}
        defaultCenter={{ lat: 22.54992, lng: 0 }}
        gestureHandling={'greedy'}
        disableDefaultUI={true}
      >
        <AdvancedMarker position={{ lat: 22.54992, lng: 0 }}>
          <CustomIcon />
        </AdvancedMarker>
      </Map>
    </APIProvider>
  )
}

Info Window (Controlled State)

import { APIProvider, Map, InfoWindow } from 'solid-google-maps'

const MarkerExample = () => {
  const [infoWindowOpen, setInfoWindowOpen] = createSignal(false)

  return (
    <APIProvider apiKey={API_KEY}>
      <Map
        style={{ height: '500px', width: '100%' }}
        defaultZoom={3}
        defaultCenter={{ lat: 22.54992, lng: 0 }}
        gestureHandling={'greedy'}
        disableDefaultUI={true}
      >
        <AdvancedMarker position={{ lat: 22.54992, lng: 0 }} onClick={() => setInfoWindowOpen(!infoWindowOpen())}>
          <CustomIcon />

          <InfoWindow
            open={infoWindowOpen()}
            onOpenChange={setInfoWindowOpen}
            maxWidth={200}
            headerContent={<span>Header</span>}
          >
            InfoWindow Content
          </InfoWindow>
        </AdvancedMarker>
      </Map>
    </APIProvider>
  )
}

Info Window (Anchored)

import { APIProvider, Map, InfoWindow } from 'solid-google-maps'

const AnchorExample = () => {
  const [anchor, setAnchor] = createSignal<google.maps.marker.AdvancedMarker | null>(null)

  return (
    <APIProvider apiKey={API_KEY}>
      <Map
        style={{ height: '500px', width: '100%' }}
        defaultZoom={3}
        defaultCenter={{ lat: 22.54992, lng: 0 }}
        gestureHandling={'greedy'}
        disableDefaultUI={true}
      >
        <AdvancedMarker position={{ lat: 21, lng: 0 }} onClick={(event) => setAnchor(event.marker)}>
          <CustomIcon />
        </AdvancedMarker>
        <AdvancedMarker position={{ lat: 22, lng: 0 }} onClick={(event) => setAnchor(event.marker)}>
          <CustomIcon />
        </AdvancedMarker>

        <Show when={anchor()}>
          <InfoWindow anchor={anchor()} maxWidth={200} headerContent={<span>Header</span>}>
            InfoWindow Content
          </InfoWindow>
        </Show>
      </Map>
    </APIProvider>
  )
}

Access to the Imperative API

All Components have a ref property that provides direct access to the Google Maps API. Additionally, the library provides a useMap() method that can be used to get a reference to the API. If you have multiple maps you can provide them an id prop and then use the ID in useMap(id) to specify the map you want to access. useMap() must be used inside the APIProvider component.

Testing

First, install dependencies and Playwright browsers:

pnpm install
pnpm playwright install

Then ensure you've built the library:

pnpm build

Then run the tests using your local build against real browser engines:

pnpm test

FAQs

Package last updated on 01 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc