
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
vue-geolocation-api
Advanced tools
A simple reactive wrapper for [Geolocation Web API](https://developer.mozilla.org/pt-BR/docs/Web/API/Geolocation)
A simple reactive wrapper for Geolocation Web API
Install with npm
npm install --save vue-geolocation-api
Install with yarn
yarn add vue-geolocation-api
import Vue from 'vue'
import VueGeolocationApi from 'vue-geolocation-api'
Vue.use(VueGeolocationApi/*, { ...options } */)
Add to modules section at your nuxt.config.js
module.exports = {
modules: [
'vue-geolocation-api/nuxt',
],
geolocation: {
// watch: true,
},
}
export default {
// ...
computed: {
inRange() {
const coords = this.$geolocation.coords
if (!coords) return '?'
return distanceFrom(coords, this.destination) > 150
}
}
}
Note that distanceFrom is not included in this package, if you need this feature I recommend to use with @turf/distance or geo-distance
<template>
<div>
<span v-if="$geolocation.loading">Loading location...</span>
<span v-else-if="!$geolocation.supported">Geolocation API is not supported</span>
<span v-else>Range from destination: {{ inRange ? 'Allowed' : 'Disallowed' }}</span>
</div>
</template>
export default {
// ...
watch: {
inRange(reached) {
if (reached !== true) return
console.log('Congratulations, you arrived')
this.$geolocation.watch = false // Stop watching location
}
}
}
Exposes the results from getCurrentPosition or the last result from watchPosition. Default or unavailable: null
If true, means the location is currently being executed.
If true means the location api is available in the browser. If false means the location api is not available in the browser. if null means the support wasn't verified yet.
Alias for $geolocation.position.coords
Default or unavailable: null
Alias for $geolocation.position.timestamp
Default or unavailable: null
Formatted coordinates. Default or unavailable: null
If true will initiate watchPosition
.
If false stop watchPosition
.
This property can be changed dynamically and will react to it's changes.
Defines the parameters that will be used by getCurrentPosition
and watchPosition
.
Changing this property will trigger an watchPosition
reload if currently watching.
Important: This property is only reactive if you replace it entirely. If you just want to change one options check the method setOption
Simply wraps the navigator.geolocation.getCurrentPosition
as a Promise.
Reactively updates the key
property in $geolocation.options
with value
.
Forces the $geolocation.supported
to update.
FAQs
A simple reactive wrapper for [Geolocation Web API](https://developer.mozilla.org/pt-BR/docs/Web/API/Geolocation)
The npm package vue-geolocation-api receives a total of 375 weekly downloads. As such, vue-geolocation-api popularity was classified as not popular.
We found that vue-geolocation-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.