2017 © Pedro Peláez
 

library geodistance

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

image

jackpopp/geodistance

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

  • Saturday, October 10, 2015
  • by jackpopp
  • Repository
  • 4 Watchers
  • 113 Stars
  • 8,885 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 15 Forks
  • 5 Open issues
  • 13 Versions
  • 9 % Grown

The README.md

GeoDistance

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

Setup

Add geodistance to your composer file., (*2)

"jackpopp/geodistance": "dev-master"

Add the geodistance trait to your eloquent model and lat/lng columns to your table., (*3)

<?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:, (*4)


$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:, (*5)


$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, (*6)

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

If you wish to add addtional measurements, please create a new issue., (*8)

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, (*9)

The Versions

10/10 2015

dev-query_adapters

dev-query_adapters

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jack Hannigan Popp

distance latitude longitude search searching radius miles kilometers

07/07 2015

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jack Hannigan Popp

distance latitude longitude search searching radius miles kilometers

07/07 2015

1.2.3

1.2.3.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jack Hannigan Popp

distance latitude longitude search searching radius miles kilometers

02/07 2015

1.2.2

1.2.2.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jack Hannigan Popp

distance latitude longitude search searching radius miles kilometers

01/06 2015

1.2.1

1.2.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jack Hannigan Popp

distance latitude longitude search searching radius miles kilometers

25/05 2015

1.2.0

1.2.0.0

  Sources   Download

The Requires

 

The Development Requires

by Jack Hannigan Popp

07/05 2015

1.1.5

1.1.5.0

  Sources   Download

The Requires

 

The Development Requires

by Jack Hannigan Popp

05/05 2015

1.1.4

1.1.4.0

  Sources   Download

The Requires

 

The Development Requires

by Jack Hannigan Popp

04/05 2015

1.1.3

1.1.3.0

  Sources   Download

The Requires

 

The Development Requires

by Jack Hannigan Popp

04/05 2015

1.1.2

1.1.2.0

  Sources   Download

The Requires

 

The Development Requires

by Jack Hannigan Popp

04/05 2015

1.1.1

1.1.1.0

  Sources   Download

The Requires

 

The Development Requires

by Jack Hannigan Popp

03/05 2015

1.1

1.1.0.0

  Sources   Download

The Requires

 

The Development Requires

by Jack Hannigan Popp

01/05 2015

1.0

1.0.0.0

  Sources   Download

The Requires

 

The Development Requires

by Jack Hannigan Popp