What3words Vue Components
The what3words vue components package extends the JS API as a framework wrapper for the custom elements found in the @what3words/javascript-components
package. This is exclusively for use in Vue applications. Depending on your use-case, you can alternatively utilise our native JS custom elements (@what3words/javascript-components
) as these should work given the specification's current browser compatibility and framework support.
This library was generated with Vue version 3.
Usage
What3Words Autosuggest Component
Installation
npm install @what3words/vue-components@<PACKAGE-VERSION>
Usage
<template>
<What3wordsAutosuggest :="$props">
<input
id="search-input"
type="text"
placeholder="Find your address"
autocomplete="off"
/>
</What3wordsAutosuggest>
</template>
<script lang="ts">
import {
What3wordsAutosuggest,
} from "@what3words/vue-components";
export default {
name: "Autosuggest",
components: {
What3wordsAutosuggest,
},
props: {
callback: String,
api_key: String,
headers: String,
base_url: String,
name: String,
initial_value: String,
variant: String,
typeahead_delay: Number,
allow_invalid: Boolean,
icon_visible: Boolean,
icon_size: Number,
icon_color: String,
language: String,
n_focus_results: Number,
clip_to_country: String,
clip_to_bounding_box: String,
clip_to_circle: String,
clip_to_polygon: String,
return_coordinates: Boolean,
onValue_changed: Function,
onValue_valid: Function,
onValue_invalid: Function,
onDeselected_suggestion: Function,
onSelected_suggestion: Function,
onSuggestions_changed: Function,
onCoordinates_changed: Function,
on__hover: Function,
on__focus: Function,
on__blur: Function,
on__error: Function,
},
};
</script>
<style>
</style>
What3Words Map Component
Installation
npm install @what3words/vue-components@<PACKAGE-VERSION>
Usage
<template>
<What3wordsMap :="$props">
<div slot="map" id="map-container" />
<div slot="search-control" id="search-container">
<What3wordsAutosuggest>
<input
id="search-input"
type="text"
placeholder="Find your address"
autocomplete="off"
/>
</What3wordsAutosuggest>
</div>
<div slot="current-location-control" id="current-location-container">
<button>Current Location</button>
</div>
</What3wordsMap>
</template>
<script lang="ts">
import {
What3wordsAutosuggest,
What3wordsMap,
} from "@what3words/vue-components";
export default {
name: "Map",
components: {
What3wordsAutosuggest,
What3wordsMap,
},
props: {
id: String,
api_key: String,
api_version: String,
base_url: String,
current_location: Boolean,
current_location_control_position: Number,
disable_default_ui: Boolean,
fullscreen_control: Boolean,
fullscreen_control_position: Number,
headers: String,
language: String,
lat: Number,
libraries: [String],
lng: Number,
map_api_key: String,
map_type_control: Boolean,
map_type_control_position: Number,
map_type_id: String,
marker_icon: String,
onCoordinates_changed: Function,
onSelected_square: Function,
on__error: Function,
on__load: Function,
region: String,
rotate_control: Boolean,
rotate_control_position: Number,
scale_control: Boolean,
search_control_position: Number,
selected_zoom: Number,
street_view_control: Boolean,
street_view_control_position: Number,
tilt: Number,
version: String,
watch_location: Boolean,
words: String,
zoom: Number,
zoom_control: Boolean,
zoom_control_position: Number,
},
};
</script>
<style>
html,
body {
margin: 0px;
height: 100%;
}
[slot="map"] {
width: 100vw;
height: 100vh;
}
[slot="search-control"] {
margin: 10px 0 0 10px;
}
#search-input {
width: 300px;
}
[slot="current-location-control"] {
margin: 0 10px 10px 0;
}
</style>
Last Updated: 8/5/2024
Last Updated: 7/9/2024