Solved

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

Posted on 2011-03-10
8
714 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
Industry Leaders: 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!

 
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

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 will show, step by step, how to integrate R code into a R Sweave document
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

730 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