• Reading time ~ 1 min
  • 09.07.2022

Laravel Geographical Calculator helps you implement geographical calculation with several algorithms that help you deal with coordinates.

This package has two primary uses: getting the distance between a set of coordinates and getting the center between two or more coordinates.

First, here's an example of getting the distance between multiple sets of latitude and longitude points. The GeoFacade accepts various sets of points and calculates the distance between point one and point two, then points two and three, and so on.

use \KMLaravel\GeographicalCalculator\Facade\GeoFacade;
 
$distance = GeoFacade::setPoint([22, 37])
    ->setOptions(['units' => ['km']])
    // you can set unlimited lat/long points.
    ->setPoint([33, 40])
    // get the calculated distance between each point
    ->getDistance();

You can get the center between two sets of lat/long points using the getCenter() method. Like the getDistance() method, you can call setPoint() multiple times and it will calculate the center of multiple sets of points:

// Get the calculated center between these points.
$center = GeoFacade::setPoint([22, 37])
    // you can set unlimited points.
    ->setPoint([33, 40])
    ->getCenter();

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

About author CrazyBoy49z
WORK EXPERIENCE
Contact
Ukraine, Lutsk
+380979856297