CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • New Google Maps address search available
Pages: [1]

Author Topic: New Google Maps address search available  (Read 1451 times)

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
New Google Maps address search available
April 26, 2011, 07:34:37 am
We'd had an issue for quite a while that the automatic mapping of contacts (in the UK) using the Google Maps *server API* wasn't very accurate.  However: For a while, a new version of this API has been available (no key needed): http://code.google.com/apis/maps/documentation/geocoding/index.html

This is more accurate provided you send it the right information.  I've updated our CRM/Utils/Geocode/Google.php to do this.

If you send Google a partial address with a correct postcode, then it maps it to the place not the postcode.  So this is mapped wrongly:
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=Bampton,++CA10+2QU,++United+Kingdom
While with just the postcode it's fine:
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=CA10+2QU,++United+Kingdom

For us, if there's a postcode, I remove everything previously.

Anyway, is there a way of updating the mapping for a bunch of contacts - without having to edit and save each one?

Thanks, Chris

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: New Google Maps address search available
April 26, 2011, 08:45:43 am
Nice,

Quote
If you send Google a partial address with a correct postcode, then it maps it to the place not the postcode.  So this is mapped wrongly:
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=Bampton,++CA10+2QU,++United+Kingdom
While with just the postcode it's fine:
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=CA10+2QU,++United+Kingdom

For us, if there's a postcode, I remove everything previously.

Wouldn't it be better result that you remove only if the address doesn't contain a number (eg "1 darling street"+CA10 is likely to be more precise than CA10 only?

As for your tool: bin/UpdateAddress.php geocode every address that isn't already encoded.

Could you generate a patch an submit it for api geocoding v3 ?

X+

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: New Google Maps address search available
April 26, 2011, 09:43:27 am

isnt this also very specific to UK postcodes (and countries that follow a similar style), where a post code gives u quite a small set of addresses (whereas US postcodes are quite large from an area perspective)

any chance u can file an issue and attach a patch to upgrade google.php to the latest server api. maybe making your code changes conditional to UK addresses only?
 
lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: New Google Maps address search available
April 26, 2011, 10:17:16 am
For the patch, I'll take out the extra code that removes anything before the postcode.  (I'm not sure how to make it conditional on UK anyway.)

Yes: UK postcodes usually cover only a few houses, so a full postcode such as "CA10 2QU" is just about as good as it gets, though a house number or name will obviously be best.

Thinking about it, our original problem might have been Google being fooled by some of our 'partial addresses'.  However, it's still good to use v3 of the API.

Chris

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: New Google Maps address search available
May 05, 2011, 03:25:36 am
I'm trying to attach a .patch file to a reply, but that's not allowed.  What's the recommended wayto do this?  Ta Chris

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: New Google Maps address search available
May 05, 2011, 04:28:54 am
Hi,

Create an issue http://issues.civicrm.org/jira/browse/CRM?report=com.atlassian.jira.plugin.system.project:roadmap-panel

and attach the patch (svn diff)

Looking forward to see the improvement!
Does it mean we don't need to set the api key anymore? and that we can therefore enable geo lookup by default on a civicrm install ?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: New Google Maps address search available
May 05, 2011, 05:00:39 am
Ta - I've created this issue: http://issues.civicrm.org/jira/browse/CRM-8032
Hopefully done in the right way.

Correct: an API key is no longer needed, so Google geocoding can be enabled by default.

I made the patch in Windows using local copies of the code.  Let me know if it's in the right format.

I didn't include my extra code that stripped out the part before the UK postcode, so the code should work everywhere.

Chris

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • New Google Maps address search available

This forum was archived on 2017-11-26.