# LocationInput — SvelteKit UI

Package: sveltekit-ui 1.1.94

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

Category: Input controls

Selects a geographic location using MapKit JS, optionally with search and filters for POIs/countries/addresses. Outputs place details.

Public component import: `LocationInput`

Public manager import: `create_location_input_manager`

## Usage

```svelte
<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { LocationInput, create_location_input_manager, Json, create_json_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 value_json = create_json_manager({ val: place, is_show_buttons: true })

  const manager = create_location_input_manager({
    val: place,
    mapkit_js_token: () => public_mapkit_token,
    label: "Meeting location",
    is_popover: true,
    is_popover_button: true,
    on_finish: (value) => value_json.set_val(value),
  })
</script>

<LocationInput {manager} />
<Json manager={value_json} />
```

## Configuration

### `val`

- type: object or null
- default: null
- description: Current location data (place_id, latitude, longitude, etc.). If non-null, will be used for initial map view.

### `mapkit_js_token`

- type: string
- default: null
- description: MapKit JS token for Apple Maps usage.

### `is_popover`

- type: boolean
- default: true
- description: If true, the component is rendered in a popover (centered modal).

### `is_popover_button`

- type: boolean
- default: false
- description: If true, shows a button that opens the map popover, rather than rendering inline.

### `is_show_search`

- type: boolean
- default: true
- description: If true, includes a search box for place name/POI/address search.

### `label`

- type: string or null
- default: null
- description: Label text displayed near the location input.

### `height`

- type: number (REM) or null
- default: null
- description: Map container height. If null, defaults to 'min(40rem, 50vh)'.

### `width`

- type: number (REM) or null
- default: null
- description: Map container width. If null, defaults to 'clamp(60rem, 80vw, 100%)'.

### `is_dark_color_scheme`

- type: boolean
- default: false
- description: Sets the initial map color scheme (light or dark).

### `on_finish`

- type: function
- description: Optional callback, called with final location data when finishing.

## Methods

### `initialize_map()`

- description: Loads the MapKit JS script if needed and initializes the Apple Map instance once loaded.
- parameters:
- returns: void

### `set_val()`

- description: Sets the manager's val (location object).
- parameters:
  - input: object with place info or null
- returns: void

## Returned state

### `val`

- type: object or null
- description: Selected location object with place details (latitude, longitude, name, etc.).

### `map`

- type: object or null
- description: Reference to the underlying MapKit map instance if loaded.

### `popover_manager`

- type: object
- description: Popover manager controlling the parent popover if is_popover=true.

### `popover_button_manager`

- type: object
- description: Button manager if is_popover_button=true.

### `label`

- type: string or null
- description: Display label for the location input.

### `height`

- type: string (CSS size)
- description: Map container height CSS, e.g. '40rem' or '50vh'.

### `width`

- type: string (CSS size)
- description: Map container width CSS, e.g. '60rem' or '80vw'.

### `is_show_search`

- type: boolean
- description: Whether the search UI is visible.

### `extra_popover_manager`

- type: object
- description: Popover manager for extra search filters popover.

### `extra_popover_button_manager`

- type: object
- description: Button manager that opens the extra filters popover.

### `finish_button_manager`

- type: object
- description: Button manager for final 'Finish' button in popover footer.

### `suggestions_prepped`

- type: array
- description: List of prepared search suggestions from MapKit's autocomplete results.

### `is_dark_mode_checkbox_manager`

- type: object
- description: Checkbox manager toggling the map color scheme (light/dark).

### `clear_suggestions_button_manager`

- type: object
- description: Clears the suggestions_prepped array.

### `search_text_input_manager`

- type: object
- description: Text input manager for the search query.

### `search_button_manager`

- type: object
- description: Button manager that triggers full map search by text.

### `search_filter_within_map_boundries_checkbox_manager`

- type: object
- description: Checkbox manager for restricting search to the visible map region.

### `search_filter_include_poi_categories_dropdown_manager`

- type: object
- description: Dropdown manager for specifying POI categories to include in results.

### `search_filter_exclude_poi_categories_dropdown_manager`

- type: object
- description: Dropdown manager for specifying POI categories to exclude from results.

### `search_filter_limit_to_countries_dropdown_manager`

- type: object
- description: Dropdown manager for restricting search results to specified countries.

### `search_filter_result_type_dropdown_manager`

- type: object
- description: Dropdown manager for toggling inclusion of address / POI / query / physicalFeature results.

### `search_filter_include_address_categories_dropdown_manager`

- type: object
- description: Dropdown manager for address categories to include (country, locality, postal code, etc.).

### `search_filter_exclude_address_categories_dropdown_manager`

- type: object
- description: Dropdown manager for address categories to exclude (country, locality, postal code, etc.).

### `mapkit_js_token`

- type: string or null
- description: MapKit JS token for Apple Maps usage.
