giorgiabosello/google-maps-react-markers
Acerca de
Google Maps for React 19: render any React component as a marker. Advanced markers or custom overlays, drag and drop, clustering-ready, SSR safe and fully typed.
Desarrollo web y de aplicacionesWhat you can do
- Any component is a marker. Markers are React portals: state, hooks, context and your CSS all work.
- Two renderers, one API. AdvancedMarkerElement when the map has a mapId, a custom overlay when it does not (so JSON styles keep working).
- Drag and drop with mouse, touch and keyboard, anchor, zIndex and clicks.
- Fast. Markers are created once and updated in place. The stress test renders up to 5,000 markers.
Crecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- Recopilando historial
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
Original
Render any React component as a Google Maps marker. React 19, Next.js 16, advanced markers or custom overlays, drag and drop, clustering-ready, SSR safe, fully typed.
Documentation and live demos →
Install
npm i google-maps-react-markers
# or
pnpm add google-maps-react-markers
yarn add google-maps-react-markers
bun add google-maps-react-markers
- React 19 (
reactandreact-domare peer dependencies). - ESM only. Node.js 22.12+ for server rendering and builds.
- A Google Maps Platform API key, restricted to your sites. A map ID is optional: it enables advanced markers.
Works with Next.js (App Router and Server Components), Vite, React Router, TanStack Start and Astro.
Usage
import { GoogleMap, Marker } from 'google-maps-react-markers'
export function StoreMap({ stores, onSelect }) {
return (
<GoogleMap
apiKey="YOUR_API_KEY"
mapId="YOUR_MAP_ID"
defaultCenter={{ lat: 45.44, lng: 12.32 }}
defaultZoom={6}
style={{ height: 480 }}
onChange={({ center, zoom, bbox }) => console.log(center, zoom, bbox)}
>
{stores.map((store) => (
<Marker
key={store.id}
lat={store.lat}
lng={store.lng}
anchor="bottom"
title={`${store.price} at ${store.name}`}
onClick={() => onSelect(store.id)}
>
<PriceTag price={store.price} />
</Marker>
))}
</GoogleMap>
)
}
Features
- Any component is a marker. Markers are React portals: state, hooks, context and your CSS all work.
- Two renderers, one API.
AdvancedMarkerElementwhen the map has amapId, a custom overlay when it does not (so JSONstyleskeep working). - Drag and drop with mouse, touch and keyboard,
anchor,zIndexand clicks. - Fast. Markers are created once and updated in place. The stress test renders up to 5,000 markers.
- Accessible. Clickable and draggable markers are keyboard buttons with screen reader names and announcements, on both renderers.
- SSR and React Server Components. No
windowduring render, clean hydration,'use client'included. - Hooks and controls.
useMap(),useMapsLibrary(),useGoogleMapsStatus(),<MapControl>. - Small and typed. About 6 kB brotli with the official
@googlemaps/js-api-loaderincluded, ESM only.
Upgrading from v2
v3 is a breaking release: markers go inside <Marker>, the import is named, and a few props changed. Follow the migration guide.
Contributing
See CONTRIBUTING.md.
Support
If this library saves you time, you can buy me a coffee or send a PayPal tip.
License
MIT © Giorgia Bosello
Explorar proyectos relacionados
Cargando…