Skip Navigation

[Resolved] Geolocation on page load

This support ticket is created 5 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 5 years ago.

Assisted by: Nigel.

Author
Posts
#1493503

Tell us what you are trying to do?
Retrieve user location during page load if so initial search results can be filtered by distance

Is there any documentation that you are following? No

Is there a similar example that we can see?

What is the link to your site?hidden link

#1493943

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

The browser won't let you access the user's location without them clicking an acceptance dialog, and you may not want such a dialog to appear when the page first loads because they may well dismiss that dialog until they have read the page content (that's certainly what I would do).

Once the user has denied permission to access the location it's very difficult for you to get past that, you can't ask again (you have to educate them about how to update the browser settings so that you can use the location).

So, my advice would be: don't do it.

But if you really want to, then the easiest way would be to use the DOM ready event to trigger a single line of jQuery which fires the click event on the "Use my location" button (check in the browser dev tools to see the best way to target the button for selection).