4 ms·
Simple hack of Google's JS API to geo-locate your users for free
Just realized that when you fetch Google's JS API it will include your geo-location embedded in the javascript file it returns. You can verify this by just going to http://www.google.com/jsapi in your browser and looking at google.loader.ClientLocation
You can use this easily in any javascript code you write with the following snippet:
<script src="http://www.google.com/jsapi"></script>
<script>
alert("I love living in: " + google.loader.ClientLocation.address.city);
</script>
- charliepark 17y agoThis is a really neat hack. Thanks for sharing this.
- deleted 17y ago[deleted]
- growt 17y agoI don't think this is a hack. it's documented api behavior: http://code.google.com/apis/ajax/documentation/#ClientLocation http://code.google.com/apis/ajax/documentation/#ClientLocati...
- mcherm 17y agoIt may not be a "hack", but I wasn't aware of it, so it's interesting information anyway.