Add "use my current location" button to home page

This commit is contained in:
Lance Edgar 2024-06-08 19:02:51 -05:00
parent de9980b014
commit 6df6f84afe

View file

@ -20,6 +20,18 @@ export default {
methods: {
useCurrentLocation() {
if (location.protocol == 'http:') {
alert("Sorry, this only works for secure sites.")
}
navigator.geolocation.getCurrentPosition(loc => {
this.coordinates = `${loc.coords.latitude},${loc.coords.longitude}`
this.loadCoordinates()
})
},
editLocations() {
this.$router.push('/edit-list')
},
@ -124,6 +136,16 @@ export default {
</o-button>
</div>
<br />
<div class="location">
<o-button variant="primary"
icon-right="location-dot"
expanded
@click="useCurrentLocation()">
Use My Current Location
</o-button>
</div>
</main>
</template>