?
Solved

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

Posted on 2011-03-10
8
Medium Priority
?
716 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
This article will show, step by step, how to integrate R code into a R Sweave document
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 this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

771 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