GEO
$point = Geo::point(49.4883333, 8.4647222);
echo $point->lat();
echo $point->lng();
This plugin adds basic geo search and conversion functionalities to Kirby
Geo Class Option
Geo::point($lat, $lng)
Creates a new Kirby Geo Point
Example:
Geo::point(49.4883333, 8.4647222);
Geo::point('49.4883333, 8.4647222');
Geo::point([49.4883333, 8.4647222]);
Geo::point(['lat' => 49.4883333, 'lng' => 8.4647222]);
Afterwards you can get the latitude and longitude values of the point like this:
$point = Geo::point(49.4883333, 8.4647222);
echo $point->lat();
echo $point->lng();
Geo::distance($pointA, $pointB)
Returns the distance between two geo points.
$mannheim = Geo::point(49.4883333, 8.4647222);
$hamburg = Geo::point(53.553436, 9.992247);
echo 'The distance between Mannheim and Hamburg is: ' . Geo::distance($mannheim, $hamburg);
You can also return the distance in miles instead of kilometers
echo 'The distance between Mannheim and Hamburg is: ' . Geo::distance($mannheim, $hamburg, 'mi');
Geo::niceDistance($pointA, $pointB)
Returns the distance between two geo points in a human readable way (i.e. 461.32 km)
$mannheim = Geo::point(49.4883333, 8.4647222);
$hamburg = Geo::point(53.553436, 9.992247);
echo 'The distance between Mannheim and Hamburg is: ' . Geo::niceDistance($mannheim, $hamburg);
You can also return the "nice distance" in miles instead of kilometers
echo 'The distance between Mannheim and Hamburg is: ' . Geo::niceDistance($mannheim, $hamburg, 'mi');
Geo::kilometersToMiles($km)
Converts kilometers into miles:
echo Geo::kilometersToMiles(1000);
Geo::milesToKilometers($mi)
Converts miles into kilometers:
echo Geo::milesToKilometers(1000);
Radius Filter
The plugin automatically adds a new filter for all collections, which can be used to do a radius search:
$addresses = page('addresses')->children()->filterBy('location', 'radius', [
'lat' => 49.4883333,
'lng' => 8.4647222,
'radius' => 10
]);
To make this work, the location field for each address page must be in the following format:
location: {lat},{lng}
or with a real life example:
location: 49.4883333,8.4647222
You can also filter in miles
$addresses = page('addresses')->children()->filterBy('location', 'radius', [
'lat' => 49.4883333,
'lng' => 8.4647222,
'radius' => 10,
'unit' => 'mi'
]);
Field Methods
The plugin also adds a set of field methods, which can be handy to work with locations
$field->coordinates()
Converts a field with the value format {lat},{lng} into a valid Kirby Geo Point Object:
$page->location()->coordinates()->lat();
$page->location()->coordinates()->lng();
$field->distance($point)
Calculates the distance between a location field and another Kirby Geo Point:
$hamburg = Geo::point(53.553436, 9.992247);
echo $page->location()->distance($hamburg);
Of course you can run this in miles again:
$hamburg = Geo::point(53.553436, 9.992247);
echo $page->location()->distance($hamburg, 'mi');
$field->niceDistance($point)
Returns the distance in a more human friendly format:
$hamburg = Geo::point(53.553436, 9.992247);
echo $page->location()->niceDistance($hamburg);
Related plugins
FeedReader
by Uwe Gehring

Twig Templates
by am-teich

Kirby Vite
by arnoson
Feed and Sitemap
by Bruno Meilick
Field Ecco
by Bruno Meilick
Handlebars Templates
by Bruno Meilick
HTML Purifier
by Bruno Meilick
Mobile Detect
by Bruno Meilick
Random
by Bruno Meilick
Better Search
by Bart Vandeputte

Laravel Mix Helper
by Diverently

Consent Gate
by fendinger
Choices
by hana+nils
List Methods
by hana+nils
snippetWhen Helper
by hana+nils
Tree Methods
by hana+nils
Type Methods
by hana+nils

XSLT Templates
by hana+nils
Carver
by Hash&Salt
Chopper
by Hash&Salt
Gilmour
by Hash&Salt
Highlighter
by Johann Schopplich

Blade Templates
by Lukas Leitsch
Snippet Controller
by Lukas Kleinschmidt
Likes
by Thomas GΓΌnther
Cookie Consent Modal
by Michael Scheurich
Byline
by David Somers
Feeds
by David Somers
Detect Adblock
by oweb studio

Plates
by oweb studio

Template Stacks
by oweb studio
Cookie Approval
by Timo Schneider
Related
by Sonja Broda
Similar
by Sonja Broda
KirbytextWrap
by Yoan MaliΓ©