Here are some of my slides from my CiviCON 2016 lightning talk:
EDIT: Some additional notes based on comments below and some questions emailed to me:
To get started with CiviCRM ...
I've found that if contacts have a geocode even if it's wrong, it won't update it.
You can get this situation if you import updates to addresses (like from NCOA) and don't have the import do the geocoding, which I think is the default. (Really this is a bug and I'll file an issue on it when I have a free min.)
I ended up using sql to zero out the codes.
I worked it out! Many of my contacts weren't given a country (must have been forgotten in a profile). I checked what the difference was between the handful that were working and the lots which weren't and spotted the missing country - as soon asI updated the contacts that were missing a country it started finding the longitude and latitude. Thanks for the ...
It looks like you have may not have set a command parameter in the Scheduled Job (but maybe you're adding it when you run the job via URL?). Do you have geocoding=1 in your command parameters for "Geocode and Parse Addresses"?
See Managing Scheduled Jobs from the Civi wiki for reference (2nd row of the table).
We had a similar need and used mapit: https://mapit.mysociety.org/. Every time an address is created/updated we use the mapit API to grab the associated parliamentary constituency, European region etc. It looks like the mapit API can give you England/Wales/Scotland/NI too (though it's trivial to translate from the European Region).
We did similar to @...
You need to enable Mapping and Geocoding from civicrm/admin/setting/mapping?reset=1
Enter your API Key or Application ID. An API Key is required for the Google Maps API. Refer to developers.google.com for the latest information.
Save the form and you should be able to see latitude and longitude based on your contact's address. Note that it displays when you ...
The Latitude, Longitude fields are only visible when they are enable in 'Address Editing'. To enable it navigate to Administer >> Localization >> Address settings. Check for 'Address Editing' option. Check box for Latitude, Longitude option and save the settings.
This is an oversimplification certainly but with either PostgreSQL or MySQL/MariaDB with their Spatial Extensions installed, you can perform basic geometry operations within your database quite easily. The key operation here is ST_Intersection(). You can pass the operator a set of points and a set of polygons and it will return the common set.
See also this ...
It looks like you still need to configure the job parameters for geocoding, for instance for the 'geocoding' parameter it expects 0 or 1, but literally "[0 or 1]" is being passed.
So if I want to geocode starting at cid 1 and end at cid 1000, but skip address parsing, I would pass the following parameters:
Off the top of my head, I think geocoding like this is an all or nothing thing. You can manually add the lat/long to an event location, so assuming that you don't have a whole lot of events, this should be pretty much acceptable (and just leave geocoding turned off).
With that said, no real contact details are shared with Google/Yahoo. A street address is ...
I've never done it, but I think Tyrell's SmartyStreets extension provides it.
One thing to point out, however, for anyone who does it another way: county names repeat a lot, and the ID numbers of counties in CiviCRM are totally arbitrary, unlike states. The way to look up county is to find the state and then find the county name within the state.
While the Google API has an unauthenticated limit of 2,500 requests per day per IP, using an API key currently gives free a quota of 100,000 requests per day, with additional requests by payment.
You'll need a recent-ish (4.7.9, 4.6.23 or greater) version of CiviCRM to use the API key for geocoding: CRM-18830: Google Geocoding - use SSL, restore API key.
I finally succeeded :
Administer > Settings > Addresses > Address Editing with Latitude, Longitude, and Street Address Parsing enabled
geocoding=1 and parse=0 in the Geocoding Parameters of the CRON job
You'll want to install the Geocoder extension. This represents a significant improvement on existing geocoding providers.
Google Maps API is now relatively pricey, and Open Street Maps is free. I find they give roughly comparable quality, but with the Geocoder module you can use multiple geocoders.
Just a clarification first: Parsing is different from geocoding. If all you want is to get lat and long values filled in then regular google geocoding works without parsing.
If you really want parsing, then you might be able to do it with hook_civicrm_post and when $objectName == 'Address' you can parse and adjust the address there.
Note that just for ...
This should be possible out of the box. CiviCRM has mapping capabilities documented here https://docs.civicrm.org/user/en/latest/initial-set-up/mapping/
There is an extension using open source v google mapping if you want: https://github.com/eileenmcnaughton/org.wikimedia.geocoder
Once you have your mapping working, then you should be able to do a Search ...
Google has a limit on encoding per day (2500) records, https://developers.google.com/maps/documentation/geocoding/usage-limits I suspect you've hit that limit. You can enable billing to increase your limits, $0.50 USD / 1000 additional requests, up to 100,000 daily.
Check CRM/Core/BAO/Address.php line 381-382.
// check if geocode should be skipped (can be forced with an optional parameter through the api)
$skip_geocode = (isset($params['skip_geocode']) && $params['...
You weren't imagining things. CiviCRM 4.6 and 4.7 until recently was ignoring the Google API key altogether! I'm not sure the history of that, but it would have been great if someone had documented that in the settings. As of the latest 4.6 and 4.7 the Google API key is getting recognized again (https://github.com/civicrm/civicrm-core/blob/4.6.23/CRM/Utils/...
This isn't possible out of the box but would be an awesome extension.
Assuming google is nicely geocoding your addresses for you then the minimum steps are:
install a database with spatial functions (either postgres+postgis or recent MySql (looks like >= 5.6 ought to do it)
populate a table with geometry
create a custom field (per contact probably best, ...
This sounds consistent with hitting a rate limit in Google Maps API.
If so, the fix would be to disable geocoding (as you've done) or to configure a valid API key associated with payment details so Google can bill you for geocoding.
I recently observed similar behaviour when a client was viewing large numbers of contacts in a proximity smart group - ...
I think the problem can happen if you import your 'State' as the Abbreviation. If you look in table civicrm_state_province you will see lots of States with Abbreviation CA - and unless you specify the right country it can have unexpected out comes possibly depending on which Countries you have enabled.
I think this jira address the core issue