Do I need to add the PWA plugin to my project?

I need to get the current location so I used the Get user’s location actions in Weweb and I saw the actions deprecated so Do I need to add the PWD plugin to my project?

Thank you guys!

Welcome to the community, Bill!

Yes, that’s correct. You need to add the PWA plugin and call its Geolocate action.

1 Like

I have added the PWA plugin and use Geolocation action to get user location.

But it seems no variable about location available. I have only seen in a log but not in variable.

How can I get that user location?

Thanks in advance.

My problem is solved.

I use custom javascript to retrieve a value an update into a variable.

// Check if geolocation is supported
if (navigator.geolocation) {
// Request the current position
navigator.geolocation.getCurrentPosition(successFunction, errorFunction);
} else {
console.log(“Geolocation is not supported by this browser.”);
}

// Success callback for getCurrentPosition
function successFunction(position) {
// Extract latitude and longitude from the position object
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;

// Update global variables
variables[‘d5437be2-f634-4178-b4b1-285db4840d0a’] = latitude;
variables[‘7a971419-b0e4-4047-9a4d-e5a8120be0f4’] = longitude;

// Return the updated latitude and longitude
return { latitude, longitude };
}

// Error callback for getCurrentPosition
function errorFunction() {
console.log(“Unable to retrieve your location.”);
return null;
}

You can get the coordinates from the workflows tab and then set your variable. No need to use custom JS.

1 Like

Thank you Danlopes!

It’s much easier.

Yes - Many thanks