Data displayMapCard
Searchastronomic.dev# MapCard
For one listing's card over a map pin: its photo, price, address and facts, and a link to the listing. MapView opens it for you.
Static: no JavaScript.
## Usage
```astro
import MapCard from "@astronomic/ui-pro/components/MapCard.astro";
```
## Examples
### A sale and a rental
What a pin opens: the photo, the price, the title link, the address, the facts, the open house or status, and the action. A part with nothing to show is left out.
```astro
---
import MapCard from "@astronomic/ui-pro/components/MapCard.astro";
// Your own listings and fields.
import { fields, listings } from "../_data/vega.ts";
import { toPoint } from "../_data/map.ts";
const sale = listings.find((listing) => listing.badge) ?? listings[0];
const rent = listings.find((listing) => listing.mode === "rent") ?? listings[0];
---
<!-- A pin's card: a sale with its open house, and a rental. MapView opens it over the map; here it stands alone. -->
<div class="flex flex-wrap items-start gap-6">
<MapCard listing={toPoint(sale)} fields={fields} />
<MapCard listing={toPoint(rent)} fields={fields} />
</div>
```
## Props
### MapCard
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `listing` | `MapCardData` | None | The listing (@astronomic/ui-pro/lib/listing-record.ts): id, href and title, and optional address, price, mode, status, badge, image and values. |
| `fields` | `ListingField[]` | None | The fields list: the facts line shows each card field with a shortLabel ("4 bd · 3 ba · 2,620 sq ft"). |
| `linkText` | `string` | `"See the listing"` | The action's text. |
| `closeLabel` | `string` | `"Close"` | The close button's name. MapView closes the card with it. |
| `imageSizes` | `string` | `"18rem"` | The photo's sizes attribute, for the listing's srcset. |
| `class` | `string` | None | More classes for the card, merged with cn(), so yours win on conflicts. |
Any other attribute goes on the card's <div>.
## Accessibility
- The card is a group named by the listing's title. Its Close button comes first; the title is the listing's link, and focus goes to it when a pin opens the card.
- The photo's alt is the listing's own. The price, facts and notes are plain text; a missing part is left out, never shown empty.
- Close and the action are at least 44px on a touch screen.
MapCard
ProFor one listing's card over a map pin: its photo, price, address and facts, and a link to the listing. MapView opens it for you.
- File
- MapCard.astro
- Group
- Data display
- Kind
- Static: no JavaScript
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
A sale and a rental
What a pin opens: the photo, the price, the title link, the address, the facts, the open house or status, and the action. A part with nothing to show is left out.


Force statemain.astro
examples/mapcard/main.astro
---
import MapCard from "@astronomic/ui-pro/components/MapCard.astro";
// Your own listings and fields.
import { fields, listings } from "../_data/vega.ts";
import { toPoint } from "../_data/map.ts";
const sale = listings.find((listing) => listing.badge) ?? listings[0];
const rent = listings.find((listing) => listing.mode === "rent") ?? listings[0];
---
<!-- A pin's card: a sale with its open house, and a rental. MapView opens it over the map; here it stands alone. -->
<div class="flex flex-wrap items-start gap-6">
<MapCard listing={toPoint(sale)} fields={fields} />
<MapCard listing={toPoint(rent)} fields={fields} />
</div>Minimal · Light