From 11678ac2fe50a92824f37decf32637784873f23b Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 1 Feb 2024 17:29:29 +0100 Subject: [PATCH] :pencil: Add geo location set variable example --- .../docs/editor/blocks/logic/set-variable.mdx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/docs/editor/blocks/logic/set-variable.mdx b/apps/docs/editor/blocks/logic/set-variable.mdx index c1082a67a..4b43ae60f 100644 --- a/apps/docs/editor/blocks/logic/set-variable.mdx +++ b/apps/docs/editor/blocks/logic/set-variable.mdx @@ -121,3 +121,23 @@ This value block allows you to find the `Id` from `Ids` with the same index as ` alt="Set variable map item with same index" /> + +## Get user's geo location + +For this you can provide the following custom code: + +```js +function getPosition() { + return new Promise((resolve, reject) => { + navigator.geolocation.getCurrentPosition( + (position) => resolve(position), + (error) => reject(error), + { enableHighAccuracy: true, timeout: 5000 } + ) + }) +} + +const coords = (await getPosition()).coords + +return `${coords.latitude}, ${coords.longitude}` +```