falco442/gps 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

falco442/gps

Composer 安装命令:

composer require falco442/gps

包简介

Gps plugin for CakePHP

README 文档

README

This plugin enable the search for some entity, given its coordinates.

Requirements:

  • CakePHP 3.x

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.

Setting up the code

Add in config/bootstrap.php the line

Plugin::load('Gps');

and in src/Model/Table/YourModelTable.php the lines

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:

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.

Usage

in src/Controller/YourModelController, for example, in a nearBy action, you could have

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:

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

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-11-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固