-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeoLoc4Flow.js
31 lines (25 loc) · 1.08 KB
/
geoLoc4Flow.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { LightningElement, track, api } from 'lwc';
import { FlowAttributeChangeEvent, FlowNavigationNextEvent } from 'lightning/flowSupport';
export default class GeoLoc4Flow extends LightningElement {
@api latitude = 0;
@api longitude = 0;
@api noGeo = false;
handleInit(event) {
this.latitude = 0;//position.coords.latitude;
this.longitude = 0;//position.coords.longitude;
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition((position) => {
this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude;
});
} else {
noGeo = True;
}
const dispatchLat = new FlowAttributeChangeEvent('latitude', this.latitude);
const dispatchLong = new FlowAttributeChangeEvent('longitude', this.longitude);
const dispatchSupp = new FlowAttributeChangeEvent('noGeo', this.noGeo);
this.dispatchEvent(dispatchLat);
this.dispatchEvent(dispatchLong);
this.dispatchEvent(dispatchSupp);
}
}