Easily get user's geographic position / location Only when the relevant screen is visible in SPA setup

I’ll leave this here cause I got stack for a while and saw other people asking about it.

If you have a SPA setup and at some point in your app something uses current geographic position it will cause the prompt to show up during the page/app load. Which is sub-optimal.

But thankfully there is a very easy workaround.

  1. Find the element that uses geographic position, say an input.
  2. Set a custom state and fill it up with a fallback address.
  3. Set the default value as the value of the custom state.
  4. Once the item is visible, trigger a “when true” workflow that changes the custom state to current geographic position.

That’s it, now the prompts loads only when the relevant screen is visible.

2 Likes

Great tip.

1 Like