I am working on a project where I need to provide a search interface for user where they will be able to search location on their country. I have use google location for this using autocomplete and get all locations from api. Is it possible to get location based on current country?
Asked
Active
Viewed 1,091 times
1 Answers
1
You can get user's current location by using geoplugin third party site using PHP:
$userIp = getenv('REMOTE_ADDR');
$geoPlugin = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$userIp"));
$user_country = $geoPlugin["geoplugin_countryName"];
$user_city = $geoPlugin["geoplugin_city"];