Sign up ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

Most sites I know of that use geolocation cause the browser to show a dialog asking the user permission to gather location info. This is like it can be seen here: and the way it works with Google Maps.

But Twitter seems to be able to do it another way. From, when you compose a Tweet, you can click a little button, and it will add your location to your Tweet.

But in the case of the twitter implementation, there is no user interruption.

How is this done?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The twitter website seems to do a XHR request to which returns the user's current location as a json object. Since location detail is about city-level, I'd guess they are using the client's IP address to locate them using a IP-Locations database.

There are numerous commercial and free API's available to match IP addresses to approximate locations, such as, if you want to do something similar.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.