Question

Geolocation for check-in without field sales module

Hi All,

 

I have a demand to create a check-in option without using the field sales module.

 

I´ve found a Javascript code that do exactly what I want, but not sure if this is the best code/option:

 

function geoFindMe() {
  const status = document.querySelector("#status");
  const mapLink = document.querySelector("#map-link");
 
  mapLink.href = "";
  mapLink.textContent = "";
 
  function success(position) {
    const latitude = position.coords.latitude;
    const longitude = position.coords.longitude;
 
    status.textContent = "";
    mapLink.href = `https://www.openstreetmap.org/#map=18/${latitude}/${longitude}`;
    mapLink.textContent = `Latitude: ${latitude} °, Longitude: ${longitude} °`;
  }
 
  function error() {
    status.textContent = "Unable to retrieve your location";
  }
 
  if (!navigator.geolocation) {
    status.textContent = "Geolocation is not supported by your browser";
  } else {
    status.textContent = "Locating…";
    navigator.geolocation.getCurrentPosition(success, error);
  }
}
 
document.querySelector("#find-me").addEventListener("click", geoFindMe);

 

Any suggestion how to get the latitude and longitude using the code above or any other suggestion on how to check-in a user without field sales module.

 

Thanks in advanced

 

Like 0

Like

1 comments

Hello Paulo,

 

I guess the best option here is to study how the check-in option works in the Field Sales module and perform the very same setup in your code.

Show all comments