Skip to content

feat(snapshot): add withAttribution option - #4461

Open
mickeypause wants to merge 2 commits into
rnmapbox:mainfrom
mickeypause:feat/snapshot-attribution
Open

mickeypause wants to merge 2 commits into
rnmapbox:mainfrom
mickeypause:feat/snapshot-attribution

Conversation

@mickeypause

@mickeypause mickeypause commented Nov 27, 2026 •

Copy link
Copy Markdown

Description

Adds withAttribution to the snapshotManager.takeSnap options.

Since #4154, withLogo: false hides the Mapbox logo on both platforms, but nothing can hide the attribution text ("© Mapbox / OpenStreetMap" on iOS, "© Mapbox / OSM" on Android). withAttribution sets the native SDKs' own switch for it: MapSnapshotOptions.showsAttribution on iOS and SnapshotOverlayOptions.showAttributes on Android. It defaults to true, as withLogo does, so existing snapshots don't change.

Attribution is still required. Hiding the text on the image is allowed only if the app shows the Mapbox and OpenStreetMap attribution elsewhere near the image (Mapbox, OSM). The Mapbox Static Images API has the same switch with the same rule.

The TakeSnapshot example scene gets a "Without Logo or Attribution" snapshot (withLogo: false, withAttribution: false) next to the existing "Without Logo" one.

Screenshots

New sample in the example app

"Without Logo" (existing) next to the new "Without Logo or Attribution", on this branch.

iOS (iPhone 16 Pro simulator, iOS 27)
Android (emulator, API 36, host GPU)

Before / after

Taken before the sample was added: the "Without Logo" snapshot in the TakeSnapshot example scene, temporarily given withAttribution: false (that one-line edit isn't part of this PR). Before: main's native code, where the option is ignored. After: this branch.

Before (main) After (this branch)
iOS (iPhone 16 Pro simulator, iOS 27)
Android (emulator, API 36)

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder (no changes)
  • I have tested the new feature on /example app.
    • In V11 mode/ios (the example app is v11 + New Architecture only)
    • In New Architecture mode/ios
    • In V11 mode/android (same)
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

Testing

  • Unit tests: SnapshotOptions.test.js checks that withAttribution defaults to true and that false is sent to the native module. yarn jest __tests__/modules/snapshot (6 tests), yarn tsc --noEmit and ESLint pass.
  • iOS: /example on an iPhone 16 Pro simulator (iOS 27, New Architecture), built once with this branch and once with main's RNMBXSnapshotModule.swift. With this branch, the snapshot with withAttribution: false has no attribution text; the default snapshots still have it.
  • Android: /example on an Android emulator (API 36, arm64, New Architecture), built the same two ways with RNMBXSnapshotModule.kt. Same result.
  • Sample: the new "Without Logo or Attribution" snapshot renders without the logo or attribution text on both platforms (Android run with the host GPU); the other snapshots are unchanged.

Component to reproduce the issue you're fixing

On main both snapshots have the attribution text, because withAttribution is ignored. With this branch, the second one has none.

Reproducer
import React, { useEffect, useState } from 'react';
import { Image, View } from 'react-native';
import { snapshotManager } from '@rnmapbox/maps';

const OPTIONS = {
  centerCoordinate: [-74.12641, 40.797968],
  zoomLevel: 13,
  width: 300,
  height: 150,
};

const BugReportExample = () => {
  const [uris, setUris] = useState([]);

  useEffect(() => {
    Promise.all([
      snapshotManager.takeSnap(OPTIONS),
      snapshotManager.takeSnap({ ...OPTIONS, withAttribution: false }),
    ]).then(setUris);
  }, []);

  return (
    <View style={{ flex: 1, padding: 16, gap: 16 }}>
      {uris.map((uri) => (
        <Image key={uri} source={{ uri }} style={{ width: 300, height: 150 }} />
      ))}
    </View>
  );
};

export default BugReportExample;

@mickeypause
mickeypause marked this pull request as draft November 27, 2026 08:43
@mickeypause
mickeypause force-pushed the feat/snapshot-attribution branch from b714912 to 9a83347 Compare November 27, 2026 11:04
mickeypause added a commit to mickeypause/maps that referenced this pull request Nov 27, 2026
mickeypause added a commit to mickeypause/maps that referenced this pull request Nov 27, 2026
@mickeypause
mickeypause force-pushed the feat/snapshot-attribution branch from 1bdc501 to e77fe65 Compare November 27, 2026 12:26
withLogo: false hides the logo on both platforms, but nothing could
turn off the attribution text. withAttribution maps onto
MapSnapshotOptions.showsAttribution on iOS and
SnapshotOverlayOptions.showAttributes on Android. It defaults to true,
as withLogo does.

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant