2

It's well known how to get geolocation, after user approval:

enter image description here

On my computer, with Firefox, the approval popup is displayed. But if I remember well, on some devices (iPad? phone?), geolocation is sometimes approved by default (is it correct?).

Is it possible to get geolocation if and only if it is possible silently (without user approval popup)? i.e. a popup will never appear, i.e. :

either it's possible to get geolocation without popup, then get it (phone, iPad), or it's not possible, then don't ask approval, don't get browser geolocation (then maybe I'll use IP-geolocation).

Basj
  • 41,386
  • 99
  • 383
  • 673
  • Good question, but not possible I think. But we'll see – Pekka Apr 24 '16 at 12:22
  • @Pekka웃 yes, I find websites that require this popup really annoying in terms of user experience : you just arrive on the website, you haven't interacted yet, and you *already* have to *make an important choice* : "should I share something personal or not?" Unconsciously, it creates a slightly bad arrival feeling on the website. It breaks the coolness flow of a website! – Basj Apr 24 '16 at 12:29
  • Yeah. Depending on what you're offering, you could use IP-based geolocation on server side, which comes with no popup at all? It's much less reliable, though. http://stackoverflow.com/questions/409999/getting-the-location-from-an-ip-address – Pekka Apr 24 '16 at 12:33

1 Answers1

1

Looks like you are requesting location data from the browser, which might be more accurate but requires approval.

If you can just get the IP of the visitor, with whatever backend language you are using on your server, you can get the location data from an IP location service like https://getipdata.com.

Whilst they're not accurate to street level, you can get a good idea about the city/state/country the user is in. That is of course, if they're not using a proxy or VPN.

Example: https://getipdata.com/8.8.8.8

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83