By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,744 Members | 1,530 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,744 IT Pros & Developers. It's quick & easy.

Determining a user's (general) location?

P: 31
I'm trying to determine the best way to figure out a user's location without asking them. It doesn't have to be wildly specific, and I'm sure it couldn't be anyways. But I have seen some kinds of "locative" functions on other websites from time to time (i.e. they know I'm getting on from wherever, Louisana and throw up an ad saying "vote for this mayor", or "Meet Singles in New Orleans", etc.)

What's the best way to figure out that information, (IP analysis? cookies? et al) and is there pre-existing code or a function out there to do it?

Thanks a LOT guys!

Dec 2 '08 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 1,208
Get a database that lets you go from ip to location. then use server side programming to locate the ip connecting to it.
Dec 2 '08 #2

Expert 100+
P: 392
This can not be done with JavaScript you will need server side code to do it. As has already been stated you will need to pull the information from one of the services that provides the location based on the user's IP address.

Be aware that these services are wildly inaccurate. The location information is based on where the IPs are registered, not their actual location. So for example even though I am actually in Kansas City, they frequently show me as in New York or California because that is where my ISP's offices are. Even if the IP location is correct it can not account for things like VPNs or other remote connections that can make it look like you are actually connecting from a different location.
Dec 2 '08 #3

rnd me
Expert 100+
P: 427
you can do it client side with the right webservices.

here's a way to get the IP: (oops)

there are a ton of geocoding jsonp webservices out there, so shop around.
you might also try simply searching google with the IP, you might find something. (you can search google from javascript using google search API)
Dec 2 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.