/ Published in: JavaScript
must also load "http://www.google.com/jsapi?key=ABQIAAAAp04yNttlQq-7b4aZI_jL5hQYPm-xtd00hTQOC0OXpAMO40FHAxQMnH50uBbWoKVHwgpklyirDEregg" as a javascript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> 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; document.getElementById('yourinfo').innerHTML = '<p>Lat/Lon: ' + visitor_lat + ' / ' + visitor_lon + '</p><p>Location: ' + visitor_city + ', ' + visitor_region + ', ' + visitor_country + ' (' + visitor_countrycode + ')</p>'; } else { document.getElementById('yourinfo').innerHTML = '<p>Whoops!</p>'; }
URL: http://briancray.com/2009/05/29/find-web-visitors-location-javascript-google-api/