jackpopp/geodistance 问题修复 & 功能扩展

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

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

jackpopp/geodistance

最新稳定版本:1.2.3

Composer 安装命令:

composer require jackpopp/geodistance

包简介

Search for locations within a radius using latitude and longitude values with your eloquent models.

README 文档

README

GeoDistance allows you to search for locations within a radius using latitude and longitude values with your eloquent models.

###Setup

Add geodistance to your composer file.

"jackpopp/geodistance": "dev-master"

Add the geodistance trait to your eloquent model and lat/lng columns to your table.

<?php namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Jackpopp\GeoDistance\GeoDistanceTrait;

class Location extends Model {

    use GeoDistanceTrait;

    protected $fillable = ['name', 'lat', 'lng'];
    
}

You can now search for locations within a distance, using miles or kilometers:

$lat = 51.4833;
$lng = 3.1833;

$locations = Location::within(5, 'miles', $lat, $lng)->get();

$locations = Location::within(5, 'kilometers', $lat, $lng)->get();

// or 

$location = new Location();
$locations = $location->lat($lat)->lng($lng)->within(5, 'miles')->get();

You can also search for locations outside a certain distance:

$lat = 51.4833;
$lng = 3.1833;

$locations = Location::outside(100, 'miles', $lat, $lng)->get();

$locations = Location::outside(100, 'kilometers', $lat, $lng)->get();

// or 

$location = new Location();
$locations = $location->lat($lat)->lng($lng)->outside(100, 'miles')->get();

Distances Available

Miles (miles/m) Kilometers (kilometers/km) Nautical Miles (nautical_miles) Feet (feet)

If you wish to add addtional measurements, please create a new issue.

Credit to movable-type.co.uk for information on selecting points withing a bounding circle - http://www.movable-type.co.uk/scripts/latlong-db.html

统计信息

  • 总下载量: 117.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 126
  • 点击次数: 1
  • 依赖项目数: 13
  • 推荐数: 0

GitHub 信息

  • Stars: 125
  • Watchers: 4
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-01