Map Pro
MapView is a slippy map in plain React Native: raster tiles from any provider, one finger to pan, two to pinch, a double tap or the wheel to zoom toward where you point, and zoom and locate buttons. Draw anything at a coordinate with MapMarker, and lines with MapRoute. There's no native module, so it runs in Expo Go, Snack and the browser, and the same code draws on all three.
Use it for delivery tracking, store finders, trip plans and dashboards. For turn-by-turn navigation, 3D buildings or offline vector maps, use a native SDK such as react-native-maps or MapLibre.
import { MapMarker, MapRoute, MapView } from '@patine-ui/pro';
<MapView fitTo={STOPS.map((s) => s.coordinate)} muted style={{ height: 420 }}> <MapRoute coordinates={STOPS.map((s) => s.coordinate)} dashed /> {STOPS.map((s, i) => ( <MapMarker key={s.id} coordinate={s.coordinate} accessibilityLabel={s.name}> <View style={{ alignItems: 'center' }}> <View style={{ paddingHorizontal: 10, paddingVertical: 4, borderRadius: 12, backgroundColor: '#111' }}> <Text size="sm" weight="semibold" style={{ color: '#fff' }}>{`${i + 1}. ${s.name}`}</Text> </View> <View style={{ width: 2, height: 10, backgroundColor: '#111' }} /> </View> </MapMarker> ))} </MapView>
Example: track a delivery
A food order on its way: the route from the restaurant to the door, the courier as a dot on it, and a card with the time left.
<View style={{ height: 440, width: '100%' }}> <MapView fitTo={ROUTE} muted style={{ flex: 1 }}> <MapRoute coordinates={ROUTE} /> <MapMarker coordinate={ROUTE[0]} accessibilityLabel="Lucia's Trattoria">{pin('store')}</MapMarker> <MapMarker coordinate={ROUTE[ROUTE.length - 1]} accessibilityLabel="Your address">{pin('home')}</MapMarker> <MapMarker coordinate={ROUTE[2]} anchor="center" accessibilityLabel="Courier, 6 minutes away"> <View style={{ width: 18, height: 18, borderRadius: 9, backgroundColor: '#1F6F64', borderWidth: 3, borderColor: '#fff' }} /> </MapMarker> </MapView> <Card style={{ position: 'absolute', left: 12, right: 12, bottom: 12 }}> <HStack gap="md" align="center" padding="md"> <Avatar name="Marco Bianchi" /> <VStack style={{ flex: 1 }}> <Text weight="semibold">Arriving in 6 min</Text> <Text size="sm" color="textSecondary">Marco is 1.2 km away · 2 items from Lucia's Trattoria</Text> </VStack> </HStack> </Card> </View>
Tiles
It opens on OpenStreetMap's own tiles, which are fine for development and light use under the OSM tile policy. For a production app, pass a provider's URL template with your key, which also brings dark and satellite styles, and its credit in attribution.
<MapView
tiles="https://api.maptiler.com/maps/dataviz/{z}/{x}/{y}.png?key=YOUR_KEY"
attribution="© MapTiler © OpenStreetMap contributors"
/>
muted drains the tiles' colour on the web, so markers and routes stand out, as dispatch and analytics maps do.
Markers and routes
A MapMarker is any view; anchor="bottom" (the default) sits its bottom on the coordinate, like a pin, and anchor="center" centres it, like a dot or a vehicle. Markers keep their size while the map pinches, and only those near the view are drawn. Give a marker onPress and an accessibilityLabel to make it a button.
MapRoute draws a line through coordinates with a white casing, solid or dashed.
Many points
clusterPoints(points, zoom, radius) groups points closer than radius points on screen, for a store finder with hundreds of pins; draw a cluster as a count and its points as markers. fitBounds(points, width, height) gives the centre and zoom that frame them, and fitTo does it for you on open.
Accessibility
- The map has the application role and your
accessibilityLabel; the zoom and locate buttons are labelled. - Markers with
onPressare buttons with their own labels, so a screen reader can reach every place without panning. For long lists, give people a list view too, as the Dispatch screen does with its panel.
Props
MapView
| Prop | Type | Default |
|---|---|---|
initialCenter | { lat, lng } | London |
initialZoom | number, 2 to 19 | 12 |
fitTo | { lat, lng }[]: opens framing these | |
onRegionChange | ({ center, zoom }) => void, when a gesture settles | |
onPress | ({ lat, lng }) => void, a tap on the map | |
tiles | string, a URL template with {z}, {x}, {y}, {s} | OpenStreetMap |
attribution | string | OpenStreetMap's |
muted | boolean | false |
controls | boolean: zoom buttons | true |
onLocate | () => void: shows a locate button |
MapMarker
| Prop | Type | Default |
|---|---|---|
coordinate | { lat, lng } | |
anchor | 'bottom' | 'center' | 'bottom' |
onPress | () => void | |
accessibilityLabel | string |
MapRoute
| Prop | Type | Default |
|---|---|---|
coordinates | { lat, lng }[] | |
color | string | The theme's primary |
width | number | 4 |
dashed | boolean | false |
Related
- Dispatch: a fleet on a map, ready to rename.