Jump to content

Google geolocation


ajetrumpet

Recommended Posts

i found the following code here: https://stackoverflow.com/questions/409999/getting-the-location-from-an-ip-address

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script>
contry_code = google.loader.ClientLocation.address.country_code
city = google.loader.ClientLocation.address.city
region = google.loader.ClientLocation.address.region
</script>

will this work to get location info?

Edited by ajetrumpet
Link to comment
Share on other sites

It will get location info, but not necessarily the correct info. For me, it returned

  • Country : GB
  • Region: West Riding of Yorkshire
  • City : Salford.

The country is correct. However I do not live in Salford or the West Riding of Yorkshire. Also, Salford is in Lancashire, not in the West Riding of Yorkshire.

I'd class it as a "Failed".

(Moved to new topic)

Link to comment
Share on other sites

45 minutes ago, gw1500se said:

IP address locations are based on the ISP location not the assigned user location.

My results could be right then - there is the possibility that my ISP is in Salford.

As for the region, it could be Google has a Londoner's view of England where anywhere beyond the end of their Northern underground line is "the North" (beware, here be dragons!)

Link to comment
Share on other sites

For the record, if you're dealing with mobile devices then you can get GPS information - if the user allows you to do so. Non-mobile devices will give you information according to the IP address (user still has to approve), which will be more or less the same as the geolocation version.

Basically, geolocation is only as good as a country and state. City is hit or miss.

Link to comment
Share on other sites

???  why do you say that?  my words indicate nothing of the sort.  they want it as easy as possible.  don't most small business people?  they don't have time to figure that crap out, nor do they care to.

Edited by ajetrumpet
Link to comment
Share on other sites

he's not doing it for that purpose Barand.  you should know, u gave me the correct script!  he wants to know where his visitors are coming from.  i regularly check that report and there are plenty of visits from google's cloud, google's bots, ms's bots and us cellular's company as well, which is our cell phone carrier.

Link to comment
Share on other sites

10 minutes ago, ajetrumpet said:

he wants to know where his visitors are coming from.

I was thinking you were using

city = google.loader.ClientLocation.address.city

which just shows location of current user (or user's proxy)

10 minutes ago, ajetrumpet said:

are you still running this consultancy?

If anyone ever contacts it. It hasn't happened yet. I was thinking of contacting the Guiness Book of Records as the world's least visited site.

Link to comment
Share on other sites

lol, nice!  you have yet to attract ONE customer!?  you've never sold anything?  i don't even have a website and i've done plenty of individual contracts!  and you mite as well contact them.  they have records for just about everything imaginable.

Edited by ajetrumpet
Link to comment
Share on other sites

actually no i didn't.  i wasn't hired for PHP.  nor was i hired for web application work.  but microsoft technologies suck, so he asked me what was available in the open source world.  small business people don't have a ton of money to spend while they are in the early stages of business, thus he asked if I would learn it to produce some small projects.  and now I will develop a mobile app for the same guy.  that will be a huge undertaking.  i'm really not looking forward to it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.