Skip to content

Instantly share code, notes, and snippets.

@LokeshSagi
Created March 28, 2020 13:33
Show Gist options
  • Save LokeshSagi/ea4c38eab3887d0d480a53475269688d to your computer and use it in GitHub Desktop.
Save LokeshSagi/ea4c38eab3887d0d480a53475269688d to your computer and use it in GitHub Desktop.
<template>
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-1 slds-medium-size_12-of-12 slds-large-size_12-of-12 slds-align_absolute-center">
<button class="slds-button slds-button_brand" onclick={handleCurrentLocation}>Get my current
location</button>
</div>
</div>
</template>
export default class CurrentLocation extends LightningElement {
handleCurrentLocation() {
navigator.geolocation.getCurrentPosition(success => {
this.showSpinner = true;
this.lat = success.coords.latitude;
this.long = success.coords.longitude;
console.log('lat -> ' + this.lat);
console.log('long -> ' + this.long);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment