1import {BeaconUtils} from 'sites/beacons/beacon_utils' 2 3export class LocationBeacon { 4 track(options = {}) { 5 if (this.isAvailable()) { 6 navigator.geolocation.getCurrentPosition((position) => { 7 const latitude = position.coords.latitude.toFixed(3) 8 const longitude = position.coords.longitude.toFixed(3) 9 10 if (options.trackable) { 11 this.send(latitude, longitude, options); 12 } 13 14 document.dispatchEvent(new CustomEvent('clinch:location:received', {detail: {latitude: latitude, longitude: longitude}})) 15 }); 16 } 17 } 18 19 isAvailable() { 20 return "geolocation" in navigator && navigator.geolocation; 21 } 22 23 send(latitude, longitude, options) { 24 BeaconUtils.transmitData(options.endpoint, { 25 candidate_location: { 26 latitude: latitude, 27 longitude: longitude, 28 kind: 'geolocation' 29 } 30 }); 31 } 32}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.