Components / Input controls
Location Input
Component + managerSelects a geographic location using MapKit JS, optionally with search and filters for POIs/countries/addresses. Outputs place details.
Live preview
Interactive exampleUsage
Import the component and its manager, then make it your own.
Component
LocationInputManager
create_location_input_manager<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} />API reference
Configure the manager, call its methods, and read its reactive state.
10 entries in configuration
| Property | Type | Default | Description |
|---|---|---|---|
val | object or null | null | Current location data (place_id, latitude, longitude, etc.). If non-null, will be used for initial map view. |
mapkit_js_token | string | null | MapKit JS token for Apple Maps usage. |
is_popover | boolean | true | If true, the component is rendered in a popover (centered modal). |
is_popover_button | boolean | false | If true, shows a button that opens the map popover, rather than rendering inline. |
is_show_search | boolean | true | If true, includes a search box for place name/POI/address search. |
label | string or null | null | Label text displayed near the location input. |
height | number (REM) or null | null | Map container height. If null, defaults to 'min(40rem, 50vh)'. |
width | number (REM) or null | null | Map container width. If null, defaults to 'clamp(60rem, 80vw, 100%)'. |
is_dark_color_scheme | boolean | false | Sets the initial map color scheme (light or dark). |
on_finish | function | — | Optional callback, called with final location data when finishing. |