Skip to content

feat: add minPitch support for MapView component - #4190

Merged
mfazekas merged 4 commits into
rnmapbox:mainfrom
kevindice:min-pitch
Nov 17, 2026
Merged

mfazekas merged 4 commits into
rnmapbox:mainfrom
kevindice:min-pitch

Conversation

@kevindice

@kevindice kevindice commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Added minPitch to MapView, mirroring maxPitch, via the SDK camera bounds options on iOS and Android. Use case: a ski area map with 3D terrain that shouldn't tilt below a given angle.

Also fixes clearing either limit: removing minPitch/maxPitch used to leave the previous limit in force (and maxPitch on iOS was never forwarded as removed). A cleared limit now resets to the SDK default (0° / 85°). minPitch is also wired through the iOS Fabric component view, without which it had no effect on iOS.

Tested with the component below (setCamera to pitch 0/89 after each prop change):

step iOS before iOS after Android before Android after
min 40, pitch 0 0 40 40 40
clear min, pitch 0 0 0 40 0
max 30, pitch 89 30 30 30 30
clear max, pitch 89 30 85 30 85

Checklist

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

Component to reproduce the issue you're fixing

import { useRef, useState } from 'react';
import { Button, Text, View } from 'react-native';
import Mapbox from '@rnmapbox/maps';

type Limit = number | undefined;

const PitchLimitsRepro = () => {
  const camera = useRef<Mapbox.Camera>(null);
  const [minPitch, setMinPitch] = useState<Limit>(undefined);
  const [maxPitch, setMaxPitch] = useState<Limit>(undefined);
  const [pitch, setPitch] = useState(0);

  const pitchTo = (p: number) =>
    camera.current?.setCamera({ pitch: p, animationDuration: 0 });

  return (
    <View style={{ flex: 1 }}>
      <Mapbox.MapView
        style={{ flex: 1 }}
        minPitch={minPitch}
        maxPitch={maxPitch}
        onCameraChanged={(s) => setPitch(s.properties.pitch)}
      >
        <Mapbox.Camera
          ref={camera}
          defaultSettings={{
            centerCoordinate: [-106.82, 39.19],
            zoomLevel: 13,
            pitch: 0,
          }}
        />
      </Mapbox.MapView>
      <Text testID="pitch-state" style={{ fontSize: 16, padding: 4 }}>
        {`pitch=${pitch.toFixed(1)} min=${minPitch ?? '-'} max=${
          maxPitch ?? '-'
        }`}
      </Text>
      <View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
        <Button testID="min40" title="min 40" onPress={() => setMinPitch(40)} />
        <Button
          testID="minclear"
          title="min clear"
          onPress={() => setMinPitch(undefined)}
        />
        <Button testID="max30" title="max 30" onPress={() => setMaxPitch(30)} />
        <Button
          testID="maxclear"
          title="max clear"
          onPress={() => setMaxPitch(undefined)}
        />
        <Button testID="pitch0" title="pitch 0" onPress={() => pitchTo(0)} />
        <Button testID="pitch89" title="pitch 89" onPress={() => pitchTo(89)} />
      </View>
    </View>
  );
};

export default PitchLimitsRepro;

@kevindice
kevindice had a problem deploying to CI with Mapbox Tokens April 2, 2026 23:11 — with GitHub Actions Failure
@kevindice
kevindice had a problem deploying to CI with Mapbox Tokens April 2, 2026 23:11 — with GitHub Actions Failure
@kevindice
kevindice had a problem deploying to CI with Mapbox Tokens April 2, 2026 23:11 — with GitHub Actions Failure
# Conflicts:
#	android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt
…cleared

Pass minPitch through the iOS Fabric component view, forward a removed
minPitch/maxPitch as nil, and reset the camera bound to the SDK default
(0 / 85 degrees) instead of keeping the previous limit.
@mfazekas

Copy link
Copy Markdown
Contributor

Thanks for this! I merged main and pushed a small follow-up: minPitch is now wired through the iOS Fabric component view (without it the prop had no effect on iOS), and removing minPitch/maxPitch now resets to the SDK defaults instead of keeping the old limit. Tested on iOS and Android; the repro and results are in the description.

@mfazekas
mfazekas merged commit 1bdd4e8 into rnmapbox:main Nov 17, 2026
10 checks passed

This branch had an error being deployed

1 failed (outdated) and 1 inactive deployments
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.

2 participants