jackpopp/geodistance
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
jackpopp/geodistance 适用场景与选型建议
jackpopp/geodistance 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 123.31k 次下载、GitHub Stars 达 125, 最近一次更新时间为 2015 年 05 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「search」 「distance」 「miles」 「kilometers」 「latitude」 「longitude」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jackpopp/geodistance 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jackpopp/geodistance 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jackpopp/geodistance 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Vars is a simple to use and easily extendable configuration loader with in built loaders for ini, json, PHP, toml, XML and yaml/yml file types. It also comes with in built support for Silex and more frameworks to come soon.
Get distance between two locations using PHP.
A Laravel package to retrieve data from Google Search Console
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
Abstraction Layer to index and search entities
Pimcore 10.x Website Indexer (powered by Zend Search Lucene)
统计信息
- 总下载量: 123.31k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 126
- 点击次数: 26
- 依赖项目数: 13
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-01