Components
MapView
MapView embeds a coordinate-based map surface using a web map provider while keeping SwiftUI's location-focused mental model.
Example
Requires React 18.2+ or 19 and shared styles. See setup.
Default
Loading preview…
Code
'use client';
import { MapView } from '@swiftuijs/ui';
export default function Example() {
return (<MapView latitude={37.3346} longitude={-122.009} title="Apple Park" zoom={14}></MapView>);
}Status: adapted
SwiftUI Correspondence: Adapted from SwiftUI's Map.
Naming note: The public React API uses MapView to avoid colliding with JavaScript's built-in Map.
Usage and limitations
- The current implementation uses an embedded OpenStreetMap view.
- Interactive controls come from the provider iframe rather than a custom renderer.
- Prefer
coordinateRegionwhen the surrounding screen already models a center/span region. - Use
annotations,selection, anddefaultSelectionto model the currently selected place in a SwiftUI-like way. - Use
openLabelandonOpento align the fallback link with the rest of your UI copy and analytics.
More examples
City Landmark
Region
With Annotations
API reference
| Prop | Type | Required | Description |
|---|---|---|---|
latitude | number | Yes | — |
longitude | number | Yes | — |
zoom | number | No | — |
title | string | No | — |
annotations | Array<{
id: string
title: string
latitude: number
longitude: number
}> | No | — |
selection | string | No | — |
defaultSelection | string | No | — |
onSelectionChange | (id: string) => void | No | — |
coordinateRegion | {
center: {
latitude: number
longitude: number
}
span?: {
latitudeDelta: number
longitudeDelta: number
}
} | No | — |
openLabel | string | No | — |
onOpen | () => void | No | — |
Inherits additional props from IBaseComponent.