Skip to content

About

Lightweight Google Maps for React Native (iOS, Android, web)

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

80 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-google-maps

Google Maps for React Native on Android, iOS and web. Fast with thousands of markers.
A thin Expo module over the official Maps SDKs. Markers are data, not views. Only what changed crosses the bridge.

Android | iOS | Web Expo SDK 57+ New Architecture only MIT license

Quickstart · Benchmarks · How it stays fast · API · Migrating · Platforms · Design

At 2000 markers on Android, react-native-google-maps has 32 ms p99 frames against 400 ms (react-native-maps image markers) and 4400 ms (view markers), a 26 ms icon swap against 185 and 291 ms, and 187 MB of memory against 337 and 525 MB. On iOS it grows by 29 MB over eight open/back cycles against 93 and 135 MB.

What it is

One <GoogleMap> component and one TypeScript API, backed by the Maps SDK for Android, the Maps SDK for iOS (Google Maps, not Apple Maps) and the Maps JavaScript API on web, through react-native-web or in a plain React DOM app (Next.js, Vite…), with server rendering.

It started as the replacement for react-native-maps in the Bounce apps, where an Android memory leak and a search map with hundreds of store pins left a slow UI thread and a growing heap. It deliberately does less than react-native-maps:

  • Much faster with many markers. At 2000 markers on Android, react-native-maps stalls the UI thread for 400 ms to 4.4 s per bad frame. react-native-google-maps stays at 32 ms, the same as at 300. Numbers below.
  • Close to the bare SDKs. The library adds an id-keyed diff, an icon cache, lifecycle wiring and fixes for a few SDK bugs. Everything else is the SDK.
  • Android, iOS and web from one API. The differences that remain are listed, not discovered.
  • Built on modern Expo. An Expo module for the New Architecture (Fabric + JSI) only, with no legacy bridge code paths.

Quickstart

Requires Expo SDK 57+ with the New Architecture (the default), iOS 16.4+, and a Google Maps API key for each platform you ship.

npx expo install @bounceapp/react-native-google-maps

Native keys go where Expo's built-in config already puts them, so the config plugin is only needed to change the Maps SDK version (see Maps SDK version):

// app.json
{
  "expo": {
    "ios": { "config": { "googleMapsApiKey": "…" } },
    "android": { "config": { "googleMaps": { "apiKey": "…" } } }
  }
}

Then rebuild the native app (npx expo prebuild or npx expo run:ios|android). On web, pass apiKey (and mapId, which markers need) as props. A React DOM app needs no react-native-web (details).

import { GoogleMap, type GoogleMapRef, type MarkerData } from '@bounceapp/react-native-google-maps';

export function StoreMap({ stores, focusedId, onFocus }: Props) {
  const mapRef = useRef<GoogleMapRef>(null);

  const markers = useMemo<MarkerData[]>(
    () =>
      stores.map((store) => ({
        id: store.id,
        coordinate: store.coordinate,
        icon: store.id === focusedId ? require('./pin-focused.png') : require('./pin.png'),
        zIndex: store.id === focusedId ? 1 : 0,
        accessibilityLabel: store.name,
      })),
    [stores, focusedId],
  );

  return (
    <GoogleMap
      ref={mapRef}
      style={{ flex: 1 }}
      initialCamera={{ center: { latitude: 38.72, longitude: -9.14 }, zoom: 13 }}
      markers={markers}
      padding={{ top: 0, right: 0, bottom: 300, left: 0 }}
      onMarkerPress={({ id }) => onFocus(id)}
      onCameraIdle={({ camera, bounds, gesture }) => {}}
      apiKey={WEB_MAPS_KEY} // web only
      mapId={WEB_MAP_ID} // web only, required for markers
    />
  );
}

await mapRef.current?.animateCamera({ zoom: 15 }, { duration: 300 });
await mapRef.current?.fitBounds(coordinates, { padding: 24 });

Note

On iOS the Maps SDK is downloaded by the podspec at pod install (Google now ships it only through Swift Package Manager), so the first install needs network access. An app with another pod that depends on the GoogleMaps pod, such as react-native-maps, would link the SDK twice: use the GoogleMaps pod instead, as below.

Maps SDK version

An app holds one copy of each Maps SDK. When another library in the app links its own (such as react-native-maps), use the config plugin to build this library against the same version:

// app.json
{
  "expo": {
    "plugins": [
      [
        "@bounceapp/react-native-google-maps",
        {
          "android": { "playServicesMapsVersion": "19.1.0" },
          "ios": { "googleMapsPodVersion": "9.4.0" }
        }
      ]
    ]
  }
}
Option Default Effect
android.playServicesMapsVersion 20.1.0 Version of com.google.android.gms:play-services-maps. A root ext.googlePlayServicesMapsVersion in android/build.gradle still wins.
ios.googleMapsPodVersion unset: the vendored GoogleMaps 11.2.0 xcframework Depend on the GoogleMaps CocoaPod at this version instead of vendoring the SDK. Google published the pod up to 10.15.

Both options are optional. Re-run npx expo prebuild after changing them. The plugin writes rnGoogleMaps.playServicesMapsVersion to android/gradle.properties and rnGoogleMaps.googleMapsPodVersion to ios/Podfile.properties.json, so a bare React Native app can set those keys by hand. The library is built against play-services-maps 19.1.0 and GoogleMaps 9.4.0 (the versions react-native-maps uses) as well as the defaults; older versions are not checked.

Benchmarks

The bench app mounts the same N markers through react-native-google-maps and through react-native-maps in two ways: native image markers with tracksViewChanges={false} (its fast path) and a child <Image> per marker (the common pattern). A run is ten icon swaps 300 ms apart, then four camera zooms. Release builds, JS bundled, tiles cached by a warm-up pass, three rounds with the libraries interleaved, medians reported.

Android. Measured on a Pixel emulator (Android 16), react-native-maps 1.29.11, React Native 0.86.3, 2026-10-17.

markers library icon swap (JS) UI frame p90 UI frame p99 memory (PSS)
300 react-native-google-maps 6 ms 31 ms 46 ms 175 MB
300 react-native-maps (image) 23 ms 26 ms 97 ms 191 MB
300 react-native-maps (view) 56 ms 26 ms 42 ms 207 MB
2000 react-native-google-maps 26 ms 17 ms 32 ms 187 MB
2000 react-native-maps (image) 185 ms 250 ms 400 ms 337 MB
2000 react-native-maps (view) 291 ms 57 ms 4400 ms 525 MB

iOS. Measured on an iPhone 17 Pro simulator (iOS 26.5), react-native-maps 1.29.11 on its Google provider vs react-native-google-maps on GoogleMaps 11.2.0, 2026-10-18. Each library is its own build, run back to back on the same simulator.

markers library icon swap (JS) JS frames dropped memory (RSS) growth over 8 open/back
2000 react-native-google-maps 24.0 ms 4 / 360 571 MB +29 MB
2000 react-native-maps (image) 21.5 ms 0 / 376 600 MB +93 MB
2000 react-native-maps (view) 53.9 ms 11 / 352 740 MB +135 MB

What the numbers say, and what they don't:

  • At 300 markers nothing is slow. Frame times are within the emulator's noise. react-native-google-maps does 4–9× less JS work per update and uses less memory, but you won't see a frame rate difference.
  • At 2000 markers react-native-maps freezes on Android. Its JS commit looks cheap because the marker views are built on the UI thread afterwards, and that is where the 250 ms p90 and 4.4 s p99 frames come from. react-native-google-maps' frames don't change between 300 and 2000.
  • On iOS the JS-side numbers are even. The iOS SDK handles markers well, and the simulator can't measure UI-thread frames. The difference is memory over navigation: 29 MB of growth against 93–135 MB.
  • An emulator on a laptop is not a low-end phone. Compare the libraries with each other, not with your device.

Full tables are in docs/DESIGN.md. To reproduce, see AGENTS.md (including its known bench-script bug).

How it stays fast

Markers are plain objects, not components. react-native-maps renders every marker as a React view backed by a native view, which Android snapshots to a bitmap and keeps in sync. That is the cost in the chart above. Here markers is an array of data:

  1. JS keeps the previous array and diffs it by id. An entry with the same reference as last time costs nothing; a rebuilt one costs a shallow field compare.
  2. Only upserts and removals cross to native, in one call.
  3. Native keeps id → SDK marker and sets only the fields that changed.
  4. Icons are decoded once per (image, size) and shared across every map in the process, so 2000 pins with three icon variants mean three bitmaps.
  5. A tap sends back only the marker's id.

Polylines, polygons and circles work the same way.

Events fire once, not per frame. onCameraIdle fires when a move ends, with the camera, bounds and whether a gesture caused it. There is no per-frame region event to throttle.

Built for the New Architecture. Diffs go to native through Expo view functions (JSI calls on the native view) instead of props, so a marker update never re-sends the whole array and never re-applies on an unrelated re-render. Android records are @OptimizedRecords, converted without reflection.

The lifecycle is a state machine. On Android a MapView is created exactly once per view and only paused and resumed on detach and re-attach. Re-creating it on every re-attach leaked a ~4 MB renderer each time in the app this replaced. A memory regression test pushes and pops a 300-marker map in a loop and fails if the heap keeps growing.

SDK bugs are fixed, not passed on. Both native SDKs can give a tap to the wrong one of overlapping markers. Here, of the markers under the finger, the one whose anchor is nearest gets it, then the higher zIndex.

The reasoning behind each decision is in docs/DESIGN.md.

API

All props and types, with docs, are in src/components/GoogleMap/types.ts (the map's props, ref and events) and src/types.ts (markers, shapes, camera).

Data markers, polylines, polygons, circles: arrays of plain objects keyed by id
Camera initialCamera (center, zoom, bearing, tilt), padding, minZoom, maxZoom
Look mapType (normal, satellite, hybrid, terrain), mapId, mapStyle, liteMode (Android), buildingsEnabled (native), compassEnabled (native)
Gestures scrollEnabled, zoomEnabled, rotateEnabled, tiltEnabled, zoomControlsEnabled, zoomControlsPosition (web), gestureHandling (web)
Location showsUserLocation (native, needs the location permission)
Events onMapReady, onPress, onMarkerPress, onMarkerHover (web), onCameraMoveStart, onCameraIdle
Web apiKey, mapId, language, dataSet (data-* attributes; no-op on native), className (React DOM only)

Ref commands, all promises that wait for the map to be ready:

animateCamera(camera: Partial<Camera>, options?: { duration?: number; padding?: number | EdgeInsets }): Promise<void>
fitBounds(coordinates: LatLng[], options?: { padding?: number | EdgeInsets; animated?: boolean }): Promise<void>
getCamera(): Promise<Required<Camera>>
getBounds(): Promise<Bounds>

For polylines, the package also exports arcCoordinates(from, to) (a curve between two points) and decodePolyline(encoded) (Google's encoded polyline format), both returning LatLng[].

A marker is id and coordinate, plus optional icon (a require()d image or { uri }), iconSize, iconView (a view / text / image tree drawn natively), anchor, zIndex, opacity, rotation, flat, tappable, accessibilityLabel, appearAnimation (pop or fade), disappearAnimation (fade on removal, opt-in) and collisionBehavior (web). Treat the arrays as immutable and keep unchanged entries referentially stable (useMemo, or rebuild only the entries that changed); that is what makes updates free.

supportsVectorMaps() says whether the device can draw a vector map. mapId is read once, when the map is created, so use it to pick a vector or a raster map ID before the map mounts:

import { supportsVectorMaps } from '@bounceapp/react-native-google-maps';

const WEB_MAP_ID = supportsVectorMaps() ? VECTOR_MAP_ID : RASTER_MAP_ID;

In a server render it returns false. That's fine for mapId, read only in the browser; to render the result as content, read it in an effect so hydration matches.

Scope

Out of scope until a consumer needs them: callouts and info windows, custom React views as markers, heatmaps, KML/GeoJSON, tile overlays, Apple Maps, and built-in clustering. If you need those today, react-native-maps is the better choice.

Coming from react-native-maps

react-native-maps react-native-google-maps
<MapView provider={PROVIDER_GOOGLE}> <GoogleMap> (always Google)
<Marker coordinate image anchor zIndex /> children markers={[{ id, coordinate, icon, anchor, zIndex }]}
<Marker> with view children (a label, a badge) iconView: a plain view / text / image tree the library draws natively
<Polyline strokeColor strokeWidth lineDashPattern /> polylines={[{ id, coordinates, color, width, dashPattern }]}
<Polygon>, <Circle> children polygons, circles props
initialRegion (deltas) initialCamera (center, zoom)
onRegionChangeComplete onCameraIdle
mapPadding padding
customMapStyle mapStyle
pitchEnabled tiltEnabled
fitToCoordinates(coords, { edgePadding }) fitBounds(coords, { padding })
getMapBoundaries() getBounds()

Platform differences

Android iOS Web
Maps SDK play-services-maps 20.1.0, or playServicesMapsVersion GoogleMaps 11.2.0 (vendored), or the GoogleMaps pod at googleMapsPodVersion Maps JS API (latest)
padding SDK padding SDK padding keeps the camera target in the middle of the view minus it, in moves, initialCamera, getCamera and camera events; changing it doesn't move the map; logo and controls stay put
tappable: false tap falls through tap falls through not clickable
Tap on overlapping markers the marker whose anchor is nearest the finger, then the higher zIndex same the marker drawn on top (Maps JS gives the click to the topmost element)
onMarkerHover – (no hover on touch) – mouse over a tappable marker, null when it leaves
Icon that can't be loaded marker hidden, or keeps its previous icon same image hidden
liteMode ✅ – –
zoomControlsEnabled ✅ – ✅
zoomControlsPosition – (bottom right) – ✅
buildingsEnabled ✅ ✅ – (raster maps have no 3D buildings)
compassEnabled ✅ (default true) ✅ (default true, while the SDK's own default hides it) – (Maps JS has no compass)
showsUserLocation ✅ (needs permission) ✅ (needs permission) –
mapStyle ignored when mapId is set same same, and markers need a mapId, so a styled map with markers uses cloud styling
mapType ✅ ✅ ✅ (with a mapId, satellite and hybrid switch to raster rendering and take a moment to load)
supportsVectorMaps() always true always true true when the browser passes Maps JS's own vector check (WebGL 2 on a GPU not on its blocklist; raster with only WebGL 1 or a software renderer), checked once. A few rare GPUs it blocks are left out. false in a server render (see above for hydration)
Server rendering – – ✅ renders an empty container; the map loads after hydration. Give it a size in style so the page doesn't shift
animateCamera during a gesture the gesture stops it and the promise settles the SDK animates on; the promise settles at the end a drag stops it and the promise settles; a scroll-wheel zoom doesn't
Marker anchor ✅ ✅ needs a known icon size: iconSize, a require()d image, or { uri, width, height }
Markers Marker GMSMarker AdvancedMarkerElement, needs mapId (the legacy google.maps.Marker is deprecated and not used)
Marker rotation ✅ ✅ ✅
Marker collisionBehavior – – ✅ (classic native markers always show and never hide map labels)
Marker flat ✅ ✅ –
Marker iconView drawn once into a bitmap with a Canvas drawn once into an image with Core Graphics DOM elements (flexbox)
Marker iconView shadow the iOS shadow props, drawn the same way (not an elevation) ✅ box-shadow
appearAnimation: 'pop' fades and moves in, no scale (a new bitmap per frame flickers) the SDK's own pop (kGMSMarkerAnimationPop): grows from the anchor, no fade grows, fades and moves in (Web Animations API)
appearAnimation: 'fade' marker alpha (ValueAnimator), follows the animator duration scale GMSMarkerLayer opacity (Core Animation) content opacity (Web Animations API)
disappearAnimation: 'fade' marker alpha (ValueAnimator), follows the animator duration scale GMSMarkerLayer opacity (Core Animation) content opacity (Web Animations API)
Polyline dashPattern ✅ ✅ (dash lengths are converted to metres at the current zoom and redone when it changes; a line over about 10,000 dashes and gaps long at the current zoom gets longer dashes instead, as setting more takes too long) first dash/gap pair only
Polygon holes either winding either winding either winding (react-native-google-maps reverses holes that wind like the outline)

Polylines, polygons and circles are not tappable on any platform: a tap on one is a map press (onPress).

React DOM without react-native-web

A bundler that doesn't resolve React Native's platform extensions (Next.js, Vite…) gets a React DOM map that imports nothing from react-native or react-native-web. It behaves as the web column above, except:

React DOM react-native-web
style flattened (arrays merged) onto a div as CSS: numbers become pixels, React Native-only properties do nothing as on a View
testID data-testid on the div as on a View
className on the div; style applies after it, and the div has contain: layout so the map can fill it whatever position your classes give it ignored (a View takes no className)
dataSet data-* attributes on the div ({ fooBar: 1 } is data-foo-bar="1") the same, through the View
onLayout not called as on a View
Marker icon { uri }, the URL string your bundler gives for an imported image, or Next.js's imported image ({ src, width, height }) also a require()d image (Metro's asset registry)

Install it with your package manager (npm install @bounceapp/react-native-google-maps): expo and react-native are optional peer dependencies, which such an app doesn't need. The type declarations still name a few React Native types (StyleProp<ViewStyle> for style, ImageSourcePropType for icon). Without react-native installed, those props are typed any with skipLibCheck (the default in Next.js and Vite projects), and the declarations fail to type-check without it. Add react-native as a dev dependency to type-check them. Development-only warnings are on when process.env.NODE_ENV isn't production.

Testing

@bounceapp/react-native-google-maps/mock exports the same values as the package, with a GoogleMap that loads neither native code nor Maps JS. Like the map, it renders Views where the test runner resolves React Native's platform extensions (jest-expo, the React Native preset) and plain DOM elements where it doesn't (Vitest, Jest on jsdom):

// Jest (a setup file, or the top of a test)
jest.mock('@bounceapp/react-native-google-maps', () =>
  require('@bounceapp/react-native-google-maps/mock')
);

// Vitest
vi.mock('@bounceapp/react-native-google-maps', () =>
  import('@bounceapp/react-native-google-maps/mock')
);

The mock ships as ES modules, so Jest must transform it: add @bounceapp/react-native-google-maps to your transformIgnorePatterns exceptions. TypeScript finds its types through the package's exports, so moduleResolution must be bundler, node16 or nodenext (Expo's base tsconfig uses bundler), not node.

The map has the test ID google-map unless you set one. Each marker is a pressable child found by its accessibilityLabel (or test ID: its accessibilityLabel, else its id), and calls onMarkerPress({ id }) unless tappable: false. The mock fires nothing by itself; fire the map's events on it (mapReady, press, cameraMoveStart, cameraIdle, markerHover).

With React Native Testing Library, events are props on the map's View:

await render(<Screen />);
await fireEvent(screen.getByTestId('google-map'), 'mapReady'); // calls onMapReady
await fireEvent.press(screen.getByLabelText('Store 7')); // calls onMarkerPress({ id })

With React DOM Testing Library, the map is a div with a button per marker, and events are DOM events whose detail is the handler's argument:

render(<Screen />);
fireEvent(screen.getByTestId('google-map'), new CustomEvent('mapReady')); // calls onMapReady
fireEvent(screen.getByTestId('google-map'), new CustomEvent('cameraIdle', { detail: event })); // calls onCameraIdle(event)
fireEvent.click(screen.getByLabelText('Store 7')); // calls onMarkerPress({ id })

ref.getCamera() returns initialCamera plus what animateCamera merged, getBounds() returns the camera center as both corners, and fitBounds() changes nothing. decodePolyline and arcCoordinates are the real ones. supportsVectorMaps() always returns true: the real check creates a WebGL context, which jsdom lacks, so it would log an error and return false. To test a raster fallback, mock supportsVectorMaps yourself.

Development

Node is pinned in .tool-versions (mise install) and pnpm in package.json (corepack enable). One pnpm install at the root sets up the library, example/ and bench/ (one workspace, one pnpm-lock.yaml) and switches on the git hooks.

pnpm install
cp example/.env.example example/.env   # fill in dev keys; never put keys in .env.example

pnpm typecheck && pnpm lint && pnpm test   # JS: Jest on native, react-native-web and React DOM (lint is oxlint plus oxfmt; pnpm lint:fix fixes)
pnpm test:ios                               # Swift (SwiftPM, no simulator)
pnpm test:android                           # Kotlin (needs example/android, see AGENTS.md)

pnpm e2e:web             # Playwright
pnpm e2e:native          # Maestro, against a running simulator/emulator
pnpm e2e:memory:android  # store open/back loop, fails if memory keeps growing
pnpm e2e:bench:android   # bench app vs react-native-maps (release build)
pnpm e2e:bench:ios       # bench app on the simulator, one library per build (release build)

The example app in example/ has one screen per use case, each a short file in example/src/screens/ to copy from:

  • Store locator: 300 image pins; tap one to select it, then its card to open the store.
  • Pickup point picker: pins of two kinds; the selected one gets a distance label above it.
  • Address picker: a pin fixed over the middle of the map that lifts while the map is dragged, and suggested spots to tap.
  • User location label: a "You are here" label that fades out the first time the map is dragged.

Its playground has every feature on one store map with 300 markers, and runs the same flow as the Bounce search map: tap a pin to focus it, tap again to open the store, go back. Run the app with pnpm example web (the web build) or pnpm example ios / pnpm example android (expo run:*); pnpm example start starts Metro for an installed build. The library has native code, so iOS and Android need a development build, and Expo Go can't run it.

The bench/ app also links react-native-maps for the comparison. After a new run, update the tables here and in docs/DESIGN.md, and the numbers in docs/assets/bench-chart.mjs, then run it to redraw the chart.

CI (ci.yml) runs the unit tests on every push and, when the repository has the Maps key secrets, the web, iOS and Android E2E suites and the memory test. bench.yml builds the bench app on every platform and flavour. Commits and PR titles follow Conventional Commits; the lefthook commit-msg hook (commitlint) and CI check them, and a pre-commit hook runs oxlint and oxfmt on the staged src/ files.

Working on this with an AI agent? Start with AGENTS.md.

License

MIT © Bounce Inc.

About

Lightweight Google Maps for React Native (iOS, Android, web)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages