0

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?

Jacob Ewing
  • 770
  • 7
  • 22
Lionel Shrestha
  • 39
  • 2
  • 10

1 Answers1

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"];