Map
Display maps, locations and routes within the meter. Camera center, orientation, zoom and map style can be set, using path to provide route points; following the user's location requires valid positioning data.
Example
function main() {
return (
<Map
center="userLocation"
heading="northUp"
mapStyle="standard"
appearance="automatic"
showUserLocation={true}
cameraAnimation={true}
regionOffset={{ x: 0, y: 20 }}
/>
);
}
Usage
- center positions the camera; path supplies the route separately. Setting center creates no route. null separates path segments. Use cameraAnimation for camera changes. Route strokes accept Color, not gradients. Check location availability or supply fixed coordinates.
- Layout reserves space before x/y and transform are applied. Moving a child right by 20 points does not push its siblings away; use spacing or Spacer to change gaps. Rotation and scaling affect the completed View.
Properties
center?"userLocation" | "dataLocation" | MapCoordinateCamera center source: native user location, current instrument location, or fixed coordinates. Defaults to userLocation.
"userLocation"showUserLocation?booleanShow the native user-location marker when a location is available.
truepath?ReadonlyArray<MapCoordinate | null>Route coordinates in order. Null breaks a segment. Coordinates use latitude/longitude; an empty array draws no route.
[]pathStyle?MapPathStyleNative route style: Color stroke, width, cap, join, dash, outline and optional endpoint markers. Gradients are unsupported.
{stroke: $env.accent, lineWidth: 4, outlineStroke: $env.foreground, outlineWidth: 1}heading?"northUp" | "vehicle" | "path" | numberCamera heading: northUp, vehicle, path, or degrees normalized modulo 360. Path heading respects segment breaks.
"northUp"regionOffset?ViewPointCrop offset in screen points. Positive x/y moves the visible region right/down; map content moves left/up.
{x: 0, y: 0}pitch?numberCamera tilt in degrees; 0 looks straight down.
0mapStyle?"standard" | "satellite" | "hybrid"Map imagery: standard roads, satellite imagery or hybrid imagery with labels.
"standard"appearance?"automatic" | "light" | "dark"Map appearance: automatic follows the environment, or force light/dark.
"automatic"cameraAnimation?booleanAnimate native camera changes. Enabled by default; disabled on the first frame and with Reduce Motion.
trueCommon properties
width?number | "auto" | "fill"Width in points, auto sizing or parent fill.
"fill"height?number | "auto" | "fill"Height in points, auto sizing or parent fill.
"fill"x?numberVisual offset in points: x moves right, y moves down. Does not change layout space.
0y?numberVisual offset in points: x moves right, y moves down. Does not change layout space.
0transform?ViewTransformTransform the whole View without changing layout. Translation uses points; rotation/skew use degrees; scale 1 is unchanged; anchors use 0–1.
{rotation: 0}opacity?numberOpacity of the whole View: 0 is transparent, 1 is opaque.
1cornerRadius?numberCorner radius in points.
0clipped?booleanClip drawing that extends beyond the View bounds.
falseclip?"rectangle" | "ellipse"Clipping shape: rectangle or ellipse. Material also accepts false to disable clipping.
"rectangle"zIndex?numberDrawing order among siblings; larger values appear in front.
0animations?MapAnimation[]Animate a supported property when it changes. duration/delay use seconds; from/to set endpoints; repeat and autoreverse control repetition; wrap sets a periodic range.
[{property: "opacity", duration: 0.25, curve: "easeInOut"}]key?string | numberStable identity among siblings.
Practical example
function main() {
return (
<Map
width={260}
height={180}
center={{ latitude: 31.2304, longitude: 121.4737 }}
heading="northUp"
showUserLocation={false}
cameraAnimation={false}
path={[
{ latitude: 31.2304, longitude: 121.4737 },
{ latitude: 31.232, longitude: 121.476 },
null,
{ latitude: 31.235, longitude: 121.48 },
{ latitude: 31.237, longitude: 121.482 },
]}
pathStyle={{
stroke: $env.accent,
lineWidth: 4,
outlineStroke: 'white',
outlineWidth: 1,
showEndpoints: true,
}}
/>
);
}
Animation
widthheightxyopacitycornerRadiustransform.translateXtransform.translateYtransform.scaleXtransform.scaleYtransform.rotationtransform.skewXtransform.skewYtransform.anchorXtransform.anchorYregionOffset.xregionOffset.ypathStyle.lineWidthpathStyle.outlineWidthpathStyle.dashPhasepathStyle.strokepathStyle.outlineStrokeWhen omitted
The table lists omission behavior verified against implementation. Property examples are copyable syntax, not defaults. Pass explicit values for a fixed result; contextual dimensions and theme colors are not fixed constants.
| Properties | When omitted |
|---|---|
center | "userLocation" |
heading | "northUp" |
cameraAnimation | true |
mapStyle | "standard" |
appearance | "automatic" |
showUserLocation | true |
pitch | 0 |