TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Simple hack of Google's JS API to geo-locate your users for free

15 pointsby dsirokerover 15 years ago
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<p>You can use this easily in any javascript code you write with the following snippet:<p>&#60;script src="http://www.google.com/jsapi"&#62;&#60;/script&#62; &#60;script&#62; alert("I love living in: " + google.loader.ClientLocation.address.city); &#60;/script&#62;

2 comments

growtover 15 years ago
I don't think this is a hack. it's documented api behavior: <a href="http://code.google.com/apis/ajax/documentation/#ClientLocation" rel="nofollow">http://code.google.com/apis/ajax/documentation/#ClientLocati...</a>
评论 #979525 未加载
charlieparkover 15 years ago
This is a really neat hack. Thanks for sharing this.