PHP code example of falco442 / gps

1. Go to this page and download the library: Download falco442/gps library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

falco442 / gps example snippets


Plugin::load('Gps');

class ArticlesTable extends Table
{
    public function initialize(array $config)
    {
    	...
        $this->addBehavior('Gps.Gps');
        ...
    }
}

class ArticlesTable extends Table
{
    public function initialize(array $config)
    {
    	...
        $this->addBehavior('Gps.Gps',[
        	'radius'=>6896000000.231,
        	'fields'=>[
        		'latitude'=>'lat',
        		'longitude'=>'lon'
        	]
        ]);
        ...
    }
}

public function nearBy(){
	$yourmodel = $this->YourModel->find('near',['gps'=>$this->request->query]);
	$this->set(compact('yourmodel'));
	$this->set('_serialize',['yourmodel']);
}