Solved

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

Posted on 2011-03-10
8
708 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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now