Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Google Map Laravel Package

arcasolutions/google-map

Laravel package providing Google Maps integration for your app, with helpers to generate map views and include the required scripts. Useful for quickly embedding maps and configuring markers or map options within Laravel projects.

View on GitHub
Deep Wiki
Context7

Directions API

The Directions API uses widop/http-adapter which is a PHP 5.3 library for issuing http requests.

The Google Directions API is a service that calculates directions between locations using an HTTP request. You can search for directions for several modes of transportation, include transit, driving, walking or cycling. Directions may specify origins, destinations and waypoints either as text strings (e.g. "Chicago, IL" or "Darwin, NT, Australia") or as latitude/longitude coordinates. The Directions API can return multi-part directions using a series of waypoints.

Request the directions service

use Ivory\GoogleMap\Services\Directions\Directions;
use Widop\HttpAdapter\CurlHttpAdapter;

$directions = new Directions(new CurlHttpAdapter());

If you want to use it with a business account, you can read this documentation.

Request a direction

$response = $directions->route('New York', 'Washington');

The directions service allows you to route a much more advance request. If you want to learn more, you can read this documentation.

Directions response

When you have requested your direction, the returned object is an Ivory\GoogleMap\Services\Directions\DirectionsResponse. It wraps a status & routes.

Directions status

The available status are defined by the Ivory\GoogleMap\Services\Directions\DirectionsStatus constants.

// Get the status
$status = $response->getStatus();

Directions routes

A request can return many routes. The directions response wraps an array of Ivory\GoogleMap\Services\Directions\DirectionsRoute.

// Get the routes
$routes = $reponse->getRoutes();

Directions route

A directions route wraps a bound, a copyrights, legs, an overview polyline (encoded), a summary, warnings & waypoint order if you use it in your request.

// Get the routes
$routes = $reponse->getRoutes();

// Iterate each routes
foreach ($routes as $route) {

}

Bound

The bound defines the viewport bounding box of this route.

// Get the bound
$bound = $route->getBound();

Copyrights

The copyrights defines the text to be displayed for this route. You must handle and display this information yourself.

// Get the copyrights
$copyrights = $route->getCopyrights();

Directions legs

The directions legs defines an array which contains information about a leg of the route, between two locations within the given route. A separate leg will be present for each waypoint or destination specified. (A route with no waypoints will contain exactly one leg within the legs array.) Each leg consists of a series of steps.

// Get the legs
$legs = $route->getLegs();

Overview polyline

The overview polyline is an encoded polyline which represents the route.

// Get the overview polyline
$overviewPolyline = $route->getOverviewPolyline();

Summary

The summari is a short textual description for the route, suitable for naming and disambiguating the route from alternatives.

// Get the summary
$summary = $route->getSummary();

Warnings

It is an array of warnings to be displayed when showing these directions. You must handle and display these warnings yourself.

// Get the warnings
$warnings = $route->getWarnings();

Waypoint order

It contains an array indicating the order of any waypoints in the calculated route. This waypoints may be reordered if the request was passed optimize:true within its waypoints parameter.

// Get the waypoint order
$waypointOrder = $route->getWaypointOrder();

Directions leg

A directions legs wraps a distance, a durations, a start location, an end location, a start address, an end address, steps.

// Get the legs
$legs = $route->getLegs();

// Iterate each leg
foreach ($legs as $leg) {

}

Distance

It indicates the total distance covered by this leg. It represented by the Ivory\GoogleMap\Services\Base\Distance.

// Gets the distance
$duration = $leg->getDistance();

Duration

It indicates the total duration of this leg. It is represented by the Ivory\GoogleMap\Services\Base\Duration.

// Gets the duration
$duration = $leg->getDuration();

Start location

The start location is the coordinate of the start of this leg. It is represented by the Ivory\GoogleMap\Base\Coordinate.

// Gets the start location
$startLocation = $leg->getStartLocation();

End location

The end location is the coordinate of the end of this leg. It is represented by the Ivory\GoogleMap\Base\Coordinate.

// Gets the end location
$endLocation = $leg->getEndLocation();

Start Address

It contains the human-readable address (typically a street address) reflecting the start location.

// Gets the start address
$startAddress = $leg->getStartAddress();

End Address

It contains the human-readable address (typically a street address) reflecting the end location.

// Gets the end address
$endAddress = $leg->getEndAddress();

Directions Steps

A leg contains an array of steps denoting information about each separate step of the leg of the journey.

// Gets the directions steps.
$steps = $leg->getSteps();

Directions step

A step is the most atomic unit of a direction's route, containing a single step describing a specific, single instruction on the journey. E.g. "Turn left at W. 4th St." The step not only describes the instruction but also contains distance and duration information relating to how this step relates to the following step. For example, a step denoted as "Merge onto I-80 West" may contain a duration of "37 miles" and "40 minutes," indicating that the next step is 37 miles/40 minutes from this step.

A step wraps a distance, a durations, a start location, an end location, instructions, an encoded polyline & a travel mode.

// Gets the directions steps.
$steps = $leg->getSteps();

// Iterate each step
foreach ($steps as $step) {

}

Distance

It contains the distance covered by this step until the next step. This field may be undefined if the distance is unknown.

// Gets the distance.
$distance = $step->getDistance();

Duration

It contains the typical time required to perform the step, until the next step. This field may be undefined if the duration is unknown.

// Gets the duration.
$duration = $step->getDuration();

Start Location

It contains the location of the starting point of this step. It is represented by the Ivory\GoogleMap\Base\Coordinate.

// Gets the start location.
$startLocation = $step->getStartLocation();

End Location

It contains the location of the ending point of this step. It is represented by the Ivory\GoogleMap\Base\Coordinate.

// Gets the end location.
$endLocation = $step->getEndLocation();

Instructions

It contains formatted instructions for this step, presented as an HTML text string.

// Gets the instructions.
$instructions = $step->getInstructions();

Encoded polyline

It represents the step as an encoded polyline.

// Gets the encoded polyline.
$encodedPolyline = $step->getEncodedPolyline();

Travel Mode

It contains the travel mode of this step. it is represented by the Ivory\GoogleMap\Services\Base\TravelMode constants.

// Gets the travel mode.
$travelMode = $step->getTravelMode();
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky