Reputation: 449
Is it possible to get the website visitor's location without using ip address ? I'm using geoplugin in my web app to get the visitors location using the IP address which I get from
$ip = $_SERVER['REMOTE_ADDR'];
but sometimes it does not return any data?
Upvotes: 0
Views: 231
Reputation: 9979
Try W3C Geolocation API
It is an effort by the World Wide Web Consortium (W3C) to standardize an interface to retrieve the geographical location information for a client-side device. It defines a set of objects, ECMAScript standard compliant, that executing in the client application give the client's device location through the consulting of Location Information Servers, which are transparent for the application programming interface (API).
The most common sources of location information are IP address, Wi-Fi and Bluetooth MAC address, radio-frequency identification (RFID), Wi-Fi connection location, or device Global Positioning System (GPS) and GSM/CDMA cell IDs. The location is returned with a given accuracy depending on the best location information source available.
Upvotes: 0
Reputation: 12229
Yes ! Though without more details on your application, it's a bit hard to tell what to implement.
If this is a browser-based application, you could ask the browser to geolocate with navigator.geolocation.getcurrentposition
and then send that data along with the request to php in the success callback.
Note that this call requires user permission, is asynchronous, and can take a long time to return.
Upvotes: 1