Simple Way Get User Locations

First we load this api:

<script type="text/javascript" src="https://www.google.com/jsapi"></script>

Then we can get many kinds of Information likes:

if (google.loader.ClientLocation) {
 var loc = google.loader.ClientLocation;
 if (loc.latitude) {
 }
 }

There many kinds of properties we can get:

ClientLocation.latitude — supplies the low resolution latitude associated with the client's IP address
ClientLocation.longitude — supplies the low resolution longitude associated with the client's IP address
ClientLocation.address.city — supplies the name of the city associated with the client's IP address
ClientLocation.address.country — supplies the name of the country associated with the client's IP address
ClientLocation.address.country_code — supplies the name of the ISO 3166-1 country code associated with the client's IP address
ClientLocation.address.region — supplies the country specific region name associated with the client's IP address

We also can use HTML 5 Features to get User Positions:

if (navigator.geolocation)
	navigator.geolocation.getCurrentPosition(displayFunction, errorFunction);
Iklan
Perihal

Selalu berusaha menjadi lebih baik... I have a BIG DREAM

Tagged with: , ,
Ditulis dalam Tak Berkategori

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s

%d blogger menyukai ini: