Skip to content
dereuromark edited this page Oct 26, 2014 · 12 revisions

The Cake2.x documentation and a detailed article can be found at http://www.dereuromark.de/2012/06/12/geocoding-with-cakephp/

This aims to be for CakePHP3.0+ versions.

Useful tips

By default the custom finder only returns the virtual "distance" field. If you want all fields to be retrieved by default, use Query::autoFields(true) on top of your query settings:

return $this->find('all')->find('distance', $options)->where(...)->autoFields(true);

Migration guide from 2.x

  • The behavior is now added inside Table::initialize():

    public function initialize(array $config) { $this->belongsTo('Users'); $this->hasMany('Comments');

      $this->addBehavior('Geo.Geocoder', [
      		'address' => [
      			'street', 'postal_code', 'city',
      		],
      		'override' => true,
      ]);
    
      parent::initialize($config);
    

    }

  • Use the custom finder Query::find('distance', $options) instead of adding virtual fields.

  • The config option before is now on.

Clone this wiki locally