# Location — SvelteKit UI

Package: sveltekit-ui 1.1.94

Page: https://www.sveltekit-ui.com/components/location

Category: Data & content

Displays an interactive Apple map with a location pin. Show it inline or open it in a popover.

Public component import: `Location`

Public manager import: `create_location_manager`

## Usage

```svelte
<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { Location, create_location_manager } from "sveltekit-ui"

  // Replace this placeholder with your public MapKit JS token,
  // authorized for your website's domain.
  const public_mapkit_token = "YOUR_DOMAIN_AUTHORIZED_PUBLIC_MAPKIT_TOKEN"

  const place = {
    name: "Boston, Massachusetts",
    latitude: 42.3603,
    longitude: -71.0573,
    formatted_address: "Boston, MA, United States",
    country_code: "US",
  }

  const manager = create_location_manager({
    val: place,
    mapkit_js_token: () => public_mapkit_token,
    is_popover: true,
    is_inline: true,
  })
</script>

<Location {manager} />
```

## Configuration

### `val`

- type: object or null
- default: null
- description: Location data: { latitude, longitude, place_id, name, etc. }

### `height`

- type: number or null
- default: null
- description: Height of the map in rem. Defaults to 'min(40rem, 50vh)' if not set.

### `width`

- type: number or null
- default: null
- description: Width of the map in rem. Defaults to 'clamp(60rem, 80vw, 100%)' if not set.

### `is_popover`

- type: boolean
- default: false
- description: If true, displays the map in a popover triggered by a button. Otherwise, it's shown directly.

### `is_inline`

- type: boolean
- default: true
- description: If true and is_popover is also true, shows an inline button + text plus a popover. If false, hides the inline portion and you must open popover manually.

### `is_dark_color_scheme`

- type: boolean
- default: true
- description: Determines map color scheme (dark or light).

### `mapkit_js_token`

- type: string or null
- default: null
- description: Apple MapKit JS token required for loading the map.

## Methods

### `init()`

- description: Initializes state and sets up popover and token for MapKit. Called once with the config.

### `initialize_map()`

- description: Loads MapKit script (if needed) and creates the map inside `#map_{id}` with the current location. Called automatically onMount or by user if needed.

### `set_val()`

- description: Updates the `val` location data object and re-initializes the map if loaded.

## Returned state

### `val`

- type: object or null
- description: Current location data object. Setting val triggers a map re-initialization if map is loaded.

### `map`

- type: object or null
- description: Reference to the underlying mapkit.Map instance once initialized.

### `popover_manager`

- type: object
- description: Popover manager for showing/hiding the map if is_popover is true.

### `toggle_popover_manager`

- type: object
- description: Button manager that toggles the popover if is_popover is true.
