# React Native Mapbox Maps SDK (@rnmapbox/maps) ## Introduction The React Native Mapbox Maps SDK is a community-supported, open-source library that enables developers to integrate high-performance, interactive maps into React Native applications using the Mapbox Maps SDK for iOS and Android. This library provides a comprehensive set of React components that wrap Mapbox's native mapping functionality, offering declarative APIs for map rendering, camera control, data sources, layers, annotations, and offline map management. The SDK supports both the legacy architecture and React Native's new architecture (Fabric/TurboModules). The library is designed to handle complex mapping scenarios including vector and raster data visualization, custom styling with the Mapbox Style Specification, real-time user location tracking, animated markers and shapes, 3D terrain rendering, clustering, and offline map downloads. It provides imperative APIs for advanced camera movements, querying rendered features, and managing map state, while maintaining excellent performance through native implementations. The SDK supports React Native 0.69+ and requires a Mapbox access token for operation. ## Core APIs and Components ### MapView Component - Basic Map Rendering MapView is the primary container component that renders a Mapbox map and handles user interactions. ```tsx import React, { useRef } from 'react'; import { StyleSheet, View } from 'react-native'; import Mapbox, { MapView, Camera } from '@rnmapbox/maps'; Mapbox.setAccessToken('pk.eyJ1IjoibXl1c2VybmFtZSIsImEiOiJjbGV4YW1wbGUifQ.example'); const BasicMap = () => { const mapRef = useRef(null); const handleMapPress = async (feature: GeoJSON.Feature) => { const { geometry } = feature; console.log('Pressed at:', geometry.coordinates); // Query features at press location const point = geometry.coordinates as [number, number]; const renderedFeatures = await mapRef.current?.queryRenderedFeaturesAtPoint( point, ['==', 'type', 'building'], ['building-layer'] ); console.log('Features at point:', renderedFeatures); }; const handleLongPress = (feature: GeoJSON.Feature) => { console.log('Long pressed at:', feature.geometry.coordinates); }; return ( { console.log('Map idle at zoom:', state.properties.zoom); console.log('Center:', state.properties.center); }} onCameraChanged={(state) => { console.log('Camera changed:', state.properties); }} > ); }; const styles = StyleSheet.create({ page: { flex: 1 }, map: { flex: 1 }, }); export default BasicMap; ``` ### Camera Component - Viewport Control Camera controls the map's perspective including center position, zoom level, pitch, heading, and viewport padding. ```tsx import React, { useRef, useEffect } from 'react'; import { View, Button, StyleSheet } from 'react-native'; import { MapView, Camera, type CameraRef } from '@rnmapbox/maps'; const CameraControl = () => { const cameraRef = useRef(null); // Programmatic camera control const flyToNewYork = () => { cameraRef.current?.flyTo([-74.006, 40.7128], 2000); }; const moveToParis = () => { cameraRef.current?.moveTo([2.3522, 48.8566], 1000); }; const zoomIn = () => { cameraRef.current?.zoomTo(16, 500); }; const fitBounds = () => { cameraRef.current?.fitBounds( [-73.9, 40.8], // Northeast [-74.1, 40.6], // Southwest [50, 50, 50, 50], // Padding [top, right, bottom, left] 1000 // Duration ); }; const animateCamera = () => { cameraRef.current?.setCamera({ centerCoordinate: [-122.4194, 37.7749], // San Francisco zoomLevel: 14, pitch: 60, heading: 45, animationDuration: 3000, animationMode: 'flyTo', }); }; // Auto-follow user location useEffect(() => { // Camera will track user location after mount }, []); return (