Determining a user's (general) location?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cyprus106
    New Member
    • Apr 2008
    • 31

    Determining a user's (general) location?

    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!

    -M
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    Get a database that lets you go from ip to location. then use server side programming to locate the ip connecting to it.

    Comment

    • pronerd
      Recognized Expert Contributor
      • Nov 2006
      • 392

      #3
      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.

      Comment

      • rnd me
        Recognized Expert Contributor
        • Jun 2007
        • 427

        #4
        you can do it client side with the right webservices.

        here's a way to get the IP: http://app.abcnews.go.com/video/getIP (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)

        Comment

        Working...