I'm trying to duplicate the answer to this question but in CakePHP 3: Search distance between 2 points CakePHP
How do I create virtual fields on the fly for CakePHP 3?
And here's my custom finder, which of course doesn't work because of the bad virtual field creation:
protected function findByDistance($lat, $long, $distance)
{
$distanceValue = $this->calcDistance($lat, $long, $this->_properties['latitude'], $this->_properties['longitude']);
$this->virtualFields['distance'] = $distanceValue;
return $query->where(['distance <=' => $distance]);
}