Overview of MapLibre React Native
mainrnmapbox, specifically separated to provide a dedicated wrapper for the MapLibre renderer as it diverges from Mapbox.repository·main·Indexed 20 days ago
https://github.com/maplibre/maplibre-react-nativeA React Native interface for rendering high-performance vector maps using the MapLibre Native SDKs on Android and iOS. It provides a dedicated wrapper for the MapLibre renderer and includes components such as Camera, Marker, Callout, LayerAnnotation, UserLocation, and ViewAnnotation for creating interactive map experiences.
rnmapbox, specifically separated to provide a dedicated wrapper for the MapLibre renderer as it diverges from Mapbox.The RasterSource component is used to supply raster image tiles to the map. You can define the location and metadata of these tiles in two ways:
url pointing to a TileJSON configuration file.tiles prop.Metadata such as zoom levels, tile size, and coordinate schemes can be configured via props.
// Example using tiles array
<RasterSource
id="my-raster-source"
tiles={['https://example.com/tiles/{z}/{x}/{y}.png']}
/>
// Example using TileJSON URL
<RasterSource
id="my-tilejson-source"
url="https://example.com/tiles/tilejson.json"
/>You can enable point clustering on a GeoJSONSource using the following props:
cluster: Set to true to enable clustering.clusterRadius: The radius of each cluster in pixels. Default is 50. A value of 512 produces a radius equal to the width of a tile.clusterMinPoints: Minimum number of points required to form a cluster. Default is 2.clusterMaxZoom: The maximum zoom level at which to cluster points. Defaults to one zoom level less than maxzoom.clusterProperties: Custom properties for generated clusters. It uses the format { "property_name": [operator, map_expression] }, where operator is a custom reduce expression referencing the special ["accumulated"] value.<GeoJSONSource
data={myData}
cluster={true}
clusterRadius={50}
clusterMinPoints={3}
clusterMaxZoom={12}
clusterProperties={{
'population': ['sum', ['get', 'population']]
}}
/>RasterDEMSource component is a map content source that provides rasterized digital elevation model (DEM) tiles. To visualize terrain effectively, you should use RasterDEMSource in conjunction with a hillshade layer.LocationManager module provides an interface to access the device's current position and subscribe to real-time location updates. It allows you to request permissions, start/stop location tracking, and configure the minimum distance (displacement) required before a new location update is emitted.The VectorSource component is used to provide tiled vector data in Mapbox Vector Tile format to the map. You can define the location and metadata of the tiles using either a url pointing to a TileJSON specification or a tiles array containing URL templates.
<VectorSource
url="https://example.com/tiles/v1.json"
/>
// OR
<VectorSource
tiles={["https://example.com/vector-tiles/{z}/{x}/{y}.pbf"]}
/>When adding visual elements to a map, choose between four primary methods based on your requirements for interactivity, styling, and performance:
Best for simple, high-performance circular points that need to support clustering and expression-based styling.
children views.Best for icon-based annotations that require clustering or expression-based styling.
Best for displaying React Native components on the map with varying levels of platform support.
org.maplibre.annotations.points on Android.Best for highly interactive React Native components.
children React Native view is interactive.The ViewAnnotation component represents a one-dimensional shape located at a specific geographical coordinate. It is best used when you need interactive views at specific points on the map.
When to use ViewAnnotation vs other methods:
ViewAnnotation when you need interactive views.Marker if you need interactive views (Note: on Android, ViewAnnotation child views are rendered onto a bitmap for performance).GeoJSONSource and SymbolLayer if you have a large number of points or use static images, as they offer significantly better performance.ViewAnnotation expects one child (the view to be anchored) and an optional second child which acts as a callout.
<ViewAnnotation lngLat={[longitude, latitude]}>
<View>
<Text>My Annotation</Text>
</View>
{/* Optional Callout */}
<View>
<Text>Callout Content</Text>
</View>
</ViewAnnotation>The TransformRequestManager allows you to intercept and modify HTTP requests made by MapLibre. It supports three types of transformations, which are applied in a specific order:
Important details:
add* method with an id that already exists, the manager updates the existing transformation in-place. This preserves its position in the pipeline, making it safe to update tokens or domains without disrupting the order of other transforms."debug" using LogManager.LogManager.setLogLevel("debug");In a standard React Native project (non-Expo), customizations are applied directly to native configuration files.
Add properties to your gradle.properties file. Each key must be prefixed with org.maplibre.reactnative.
Add global variables to your Podfile. Each key must be prefixed with $MLRN.
// Android: gradle.properties
org.maplibre.reactnative.nativeVersion=x.x.x
// iOS: Podfile
$MLRN_NATIVE_VERSION="x.x.x"The Camera component in v10 has undergone several changes:
animationMode for a controlled Camera is now CameraMode.None. To restore the previous automatic animation behavior, you must explicitly set animationMode="easeTo" and provide an animationDuration.allowUpdates and triggerKey props have been removed. To trigger camera updates, keep your props stable or use the imperative setCamera method on the Camera component.setCamera method has been removed from the MapView component; you must now use the imperative methods provided by the Camera component directly.// To reinstate previous animation behavior in v10:
<Camera
centerCoordinate={[0, 0]}
animationDuration={2000}
animationMode="easeTo"
/>Install the package using your preferred package manager. For example, using yarn:
yarn add @maplibre/maplibre-react-native