# React Native store locator template with map (Pro)

> A React Native store locator for iOS, Android and the web: search by area or postcode, open-now and service filters, stores nearest first in sync with a map, clusters that split as you zoom, your location, opening hours, call and directions, and a phone bottom sheet with snap points. No native modules.

# Store locator Pro

A store finder as retailers and Google Maps show one. Search by area, street or postcode; filter by **Open now** and services; the list is nearest first and stays in sync with the map, where stores cluster while they crowd and slide apart as you zoom. Pick a store for its hours (today in bold), address and walk, services, a call button, directions in the phone's maps app, and "make this my store". On desktops the list sits beside the map; on phones it lives in a sheet over the map that rests at a peek, half or full.

Built from [MapView](../blocks/map) (`MapClusters`, `MapUserLocation`, `MapSheet`) and free components.

```tsx
import { StoreLocatorScreen } from '@patine-ui/pro';

<StoreLocatorScreen />;
```

```tsx live full
import { View } from 'react-native';
import { StoreLocatorScreen } from '@patine-ui/pro';

export default function Example() {
  return (
    <View style={{ width: '100%', height: 680 }}>
      <StoreLocatorScreen />
    </View>
  );
}
```

## Open now, in words

`openStatus(store, now)` says what a maps app says: "Open · closes 8 PM", "Closes soon · 8 PM" within the hour (in amber), "Closed · opens 9 AM tomorrow", "Closed · opens Monday 9 AM", "Open 24 hours". Hours are per weekday in minutes after midnight, Sunday first like `Date.getDay()`, and `null` for a closed day. The screen re-checks every minute; pass `now` to pin it (for tests and screenshots).

```tsx
const store = {
  hours: [null, [540, 1200], [540, 1200], [540, 1200], [540, 1260], [540, 1260], [600, 1080]],
};
openStatus(store, new Date()); // { open: true, closingSoon: false, label: 'Open · closes 8 PM' }
```

## Make it yours

| Prop | Type | Default |
| --- | --- | --- |
| `stores` | `Store[]`: `id`, `name`, `area`, `address`, `postcode`, `coordinate`, `phone`, `hours`, `services`, `rating`, `reviews` | The Halden demo, 19 London stores |
| `location` | `{ lat, lng }`: the person's place, from your location library | By the Strand |
| `now` | `Date` | Now, kept current |
| `onDirections` | `(store) => void` | Opens Apple Maps on iOS, Google Maps elsewhere (`directionsUrl`) |
| `onCall` | `(store) => void` | Dials the store |
| `onChooseStore` | `(store) => void`: "Make this my store" | |
| `title` | `string` | `'Find a store'` |

`findStores(stores, from, { query, openNow, services }, now)` does the search, filters and distance sort, so a server-side search can return the same shape. Services are listed in `STORE_SERVICES`; change their labels and icons there.

The map opens on OpenStreetMap's tiles, which suit development. For production, pass a provider's URL with your key to `MapView` (see [Tiles](../blocks/map#tiles)).

## Built with

The free components, from `patine-ui`:

[Button](/docs/components/button) · [Heading, Text](/docs/components/text) · [SearchField](/docs/components/search-field) · [Separator](/docs/components/separator)

And from Patine Pro:

- [App shell and layout](/docs/pro/layout) PRO
- [Map](/docs/blocks/map) PRO
- [Patine Icons, the Pro set](/docs/components/icons) PRO

## Files

```text
store-locator/
├── components/
│   ├── StoreDetail.tsx
│   ├── StoreParts.tsx
│   ├── StorePin.tsx
│   └── StoreRow.tsx
├── hooks/
│   └── useStoreLocator.ts
├── index.ts
├── store-locator.constants.ts
├── store-locator.types.ts
├── store-locator.utils.ts
└── StoreLocatorScreen.tsx
```

## A look at the code

Directions in the phone’s own maps app, and walking time, from `store-locator.utils.ts`:

```tsx
/** A link that opens directions to the store in the phone's maps app: Apple Maps on iOS, Google Maps elsewhere. */
export const directionsUrl = (store: Pick<Store, 'coordinate' | 'name'>, os: string) => {
  const { lat, lng } = store.coordinate;
  return os === 'ios'
    ? `https://maps.apple.com/?daddr=${lat},${lng}&q=${encodeURIComponent(store.name)}`
    : `https://www.google.com/maps/dir/?api=1&destination=${lat},${lng}`;
};

/** About how long a walk takes, at 5 km/h: "6 min walk", "1 h 10 min walk". */
export const walkTime = (meters: number) => {
  const min = Math.max(1, Math.round(meters / 83));
  return min < 60 ? `${min} min walk` : `${Math.floor(min / 60)} h ${min % 60} min walk`;
};
```

Get the source with Pro

## Accessibility

- Every store row and pin is a button named with the store, distance and whether it's open; the selected one is marked selected.
- Filters are checkboxes; the hours row is an expandable button.
- The sheet's handle steps through its heights on press or Enter, so it never needs a drag.
- Opening status is in words as well as colour.

## Related

- [Map](../blocks/map) · [Dispatch](./dispatch) · [Delivery tracking](./courier-tracking)
