Geo localisation par Adresse IP

Publié le 29 septembre 2010 par Capmarketer
  1. Première méthode: en JavaScript via les API Google
  2. Deuxième méthode: en PHP

Méthode I en javascript via les API Google : pour obtenir une API KEY

Step 1: Charger Google AJAX API script

1
<script type="text/javascript" src="http://www.google.com/jsapi?key=API_KEY_GOES_HERE"></script>

Step 2: Extraire la localisation par google.loader.ClientLocation

1
2
3
4
5
6
7
8
9
10
11
12
13
if(google.loader.ClientLocation)
{
	visitor_lat = google.loader.ClientLocation.latitude;
	visitor_lon = google.loader.ClientLocation.longitude;
	visitor_city = google.loader.ClientLocation.address.city;
	visitor_region = google.loader.ClientLocation.address.region;
	visitor_country = google.loader.ClientLocation.address.country;
	visitor_countrycode = google.loader.ClientLocation.address.country_code;
}
else
{
	// pas trouve
}

Continuer la lecture : 1 2 - Tout afficher

Pages:next page