Solved

England UK address returns lat and long for USA from Google geocoding

Posted on 2011-03-10
8
711 Views
Last Modified: 2012-05-11
I geocode an address below and get lat and long for the same town name in
North Carolina USA> I have tried +GB and +UK  . Other countries are ok but problems for UK
The CF code is fine - it just appears google is giving funny results.  Durham England UK gets lat long for Durham in NC USA. So what do I need to do with the data?

location = Ludworth,County Durham,England+UK
Returns
lat = 54.7665696
long = -1.4377006

Code:
</cfoutput>

<!--- function to decode the return from google --->
<cfinclude template = "jsondecode.cfm">
<cfoutput>
<cfhttp method="get"
        url="http://maps.googleapis.com/maps/api/geocode/json?address=#urlencodedformat(location)#&sensor=false"
        resolveurl="no">
</cfhttp>
<cfset GeoCodeLattitude = jsondecode(cfhttp.FileContent).results[1].geometry.location.lat />
<cfset GeoCodeLongitude = jsondecode(cfhttp.FileContent).results[1].geometry.location.lng />
</cfoutput>
0
Comment
Question by:Ian White
  • 4
  • 4
8 Comments
 

Author Comment

by:Ian White
ID: 35093621
I did some more research about region bias and added the region=uk  on the end according to google docs - but same result Google think

Ludworth,County Durham,England+UK
is in NC USA

So
<cfhttp method="get"
        url="http://maps.googleapis.com/maps/api/geocode/json?address=#urlencodedformat(location)#&sensor=false" & region=uk
        resolveurl="no">
</cfhttp>


0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 35093922
I tested it out.. seems to be the correct results...

<cfset location = 'Ludworth,County Durham,England,UK' />

<cfoutput>
<cfhttp method="get"
        url="http://maps.googleapis.com/maps/api/geocode/json?address=#urlencodedformat(location)#&sensor=false&region=uk"
        resolveurl="no">
</cfhttp>
</cfoutput>

Open in new window


Gives - 54.7665696 -1.4377006 

Open in new window


while

<cfset location = 'Durham,NC,USA' />

<cfoutput>
<cfhttp method="get"
        url="http://maps.googleapis.com/maps/api/geocode/json?address=#urlencodedformat(location)#&sensor=false"
        resolveurl="no">
</cfhttp>
</cfoutput>

Open in new window



Gives - 35.9940329 -78.898619


check the dump in BOTH cases, it shows the correct location...

<cfdump var="#jsondecode(cfhttp.FileContent)#">
0
 

Author Comment

by:Ian White
ID: 35100964
Yes it is the correct lattitude verified by

http://maps.google.com/maps?q=54.7665696,+-1.4377006+(You+can+insert+your+text+here)

However I generate the above link dynamicaly and get
<a href="http://maps.google.com/maps?q=54.7665696,+-1.4377006+(Housecarers Housesit+County Durham+Ludworth+7 miles from Durham City)">Map</a>

And this get a result:
"We could not understand this location "So it defaults to Durham in USA
Somehow it strips part of location out of the optional description

This is the only one I am having problems with the other generated links are fine
0
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 35104573
There seems to be some issue with the string which you are trying to search with

if you search with

http://maps.google.com/maps?q=54.7665696,+-1.4377006+(County Durham+BLudworth) - it gives the correct UK result, but the moment you add either 7 miles from Durham City or Housecarers Housesi, Google says it cannot find the location and by default you must be having locale as US, so it tries to give you a US result as a suggestion.
0
 

Author Comment

by:Ian White
ID: 35104951
Very Strange as it works for around 300 other cases but not this one?  The area in brakets Google provides to add description only - so you can add what you like to this free format text area. It should not form part of the google search - just lat and long is used for that.

eg the following works fine as do all others

http://maps.google.com/maps?q=51.2624605,+-1.0840243+(Housecarers+Housesit+ Near Basingstoke+Hampshire+North Hampshire)
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 35104983
Yes, it is very strange,

if you search directly at google for 'Housecarers Housesit+County Durham+Ludworth+7 miles from Durham City' it gives you correct results, the first one is http://www.housecarers.com/search_detail_housesit.cfm?mem=2145605329.

BUT if you click on MAP or use the above URL it says it cannot FIND it.. ..
0
 

Author Comment

by:Ian White
ID: 35105217
I  tested some more as soon as I remove the word "from" out of the description it works.  So Google has a bug if the word From is included in the free format description. They say to add whatever you like.

 
0
 
LVL 11

Accepted Solution

by:
Brijesh Chauhan earned 500 total points
ID: 35106342
wow.. cool.. glad that your issue is resolved, may be Google will fix it sometime soon.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question