2017 © Pedro Peláez
 

cakephp-plugin gps

Gps plugin for CakePHP

image

falco442/gps

Gps plugin for CakePHP

  • Monday, November 28, 2016
  • by falco442
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Introduction

This plugin enable the search for some entity, given its coordinates., (*1)

Requirements: * CakePHP 3.x, (*2)

Installation

Table entry

Add the fields (choose your names, or use the default 'latitude' and 'longitude'). I suggest to use the FLOAT(10,6). Note that, if you change the field names, you must provide them in the plugin configuration., (*3)

Setting up the code

Add in config/bootstrap.php the line, (*4)

Plugin::load('Gps');

and in src/Model/Table/YourModelTable.php the lines, (*5)

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

You can also provide a configuration with the plugin, extending this lines:, (*6)

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

For example, in this configuration, we're informing the plugin that the fields in the table will be of names 'lat' for latitude, and 'lon' for longitude. The Earth radius will be of 6896000000.231 km., (*7)

Usage

in src/Controller/YourModelController, for example, in a nearBy action, you could have, (*8)

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

and so the conditions will be the ones urlencoded:, (*9)

http://yourdomain.com/youmodel/near-by.json?latitude=43.2&longitude=24.356&radius=20000

With this url we're telling ours API software to take the objects in a square with center in 43.2,24.35 and side of 20000 meters, (*10)

The Versions

28/11 2016

dev-master

9999999-dev

Gps plugin for CakePHP

  Sources   Download

The Requires

 

The Development Requires

28/11 2016

v1.2

1.2.0.0

Gps plugin for CakePHP

  Sources   Download

The Requires

 

The Development Requires

22/11 2016

v1.1

1.1.0.0

Gps plugin for CakePHP

  Sources   Download

The Requires

 

The Development Requires

22/11 2016

v1.0

1.0.0.0

Gps plugin for CakePHP

  Sources   Download

The Requires

 

The Development Requires