owenmelbz/google-map-distance-calculator

Simple class for basic google maps distance calculations.

dev-master 2018-02-21 22:37 UTC

This package is auto-updated.

Last update: 2020-09-29 07:23:47 UTC


README

Allows you to return distance and duration between 2 long/lat positions

Usage

use OwenMelbz\GoogleMapDistanceCalculator\DistanceCalculator;

$maps = new DistanceCalculator($apiKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXx');

$maps->setStartingPoint(52.629129, 1.290570);
$maps->setEndPoint(52.623990, 1.304594);

$maps->setTravelMode('walking'); // default 'driving'
$maps->setFormat('xml'); // default 'json'
$maps->setUnit('metric'); // default 'imperial'

$maps->getDistance();
$maps->getDistanceInMeters();

$maps->getTravelDuration();
$maps->getTravelDurationInSeconds();

$maps->calculate(); // returns whole response from google