?
Solved

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

Posted on 2011-03-10
8
Medium Priority
?
719 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 2000 total points
ID: 35106342
wow.. cool.. glad that your issue is resolved, may be Google will fix it sometime soon.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month16 days, 8 hours left to enroll

864 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