Routing — $49, one-time
How far, and how long, to each of these.
One origin, many destinations, one call. Real road distance and travel time — the numbers you need to order a list of stores, pickup points or drivers by how long it actually takes to get there, not by a straight line on a map.
NativePHP has plugins that draw a map. This is the one that answers how far and how long.
iOS routes on the device through MapKit, free and with no key. Android has no on-device routing engine at all — Play Services Location only positions, the Maps SDK only draws, and the google.navigation: intent hands the user to the Maps app without returning anything.
So on Android the plugin talks to a routing service, and the plugin ships the adapter for five of them. The account is yours: billed to you, under that provider's terms, and any attribution they require is yours to display. We carry no quota and no key. Without a provider configured, Android falls back cleanly and tells your app so.
Providers on Android
| Mapbox | Matrix API. The free tier is metered in elements — origins × destinations. |
|---|---|
| openrouteservice | Results are licensed CC-BY-SA and attribution is required. Check both against your use before choosing it. |
| Geoapify | Commercial use allowed on the free tier, with visible attribution. |
Routes computeRouteMatrix. Billed per element. | |
| OSRM | Your own osrm-backend, or any endpoint speaking its table/route shape — including your own API proxying one of the above. |
Switching provider is one line of config. Each one speaks a different dialect — Geoapify indexes by target_index, Google returns an array with the duration as a string — and the adapters translate, so your app sees one shape.
A key in the app config ships inside the build, where anyone holding the APK can read it. For production, point the OSRM adapter at your own backend instead: the key stays on your server, results can be cached per area, and you can swap provider without shipping a new version.
What it does
- Batch, not one-by-one. Up to 25 destinations resolved in a single request, with a per-destination fallback when the server refuses a batch.
- The event always fires. On both platforms, once per call, one row per destination. A destination that could not be routed comes back with
ok: falseand a reason —unsupported,timeout,no_route,over_limit,failed. Your app falls back to a straight-line estimate on a signal, never on a timeout that never arrives. - Every request is bounded. Each destination has its own time budget, so one stalled route cannot hold the batch.
- Ask before you render.
isSupported()tells you up front whether this device can route, so you can hide an ETA column instead of filling it with blanks. - Authenticated endpoints. Send headers with every routing request, so the endpoint you point at can be your own API behind a token instead of an open server.
- Route options. Driving, walking, cycling and public transport; leave at or arrive by a given time; avoid tolls or highways. iOS applies them through MapKit, Android through whatever the provider's API offers.
- No silent fallbacks.
support()lists the transports and options this device and engine accept, so you only show the ones that work. An option the engine cannot honour fails with a reason, instead of returning a plausible time for a route nobody asked for. - Take me there.
navigate()hands the chosen destination to Apple Maps, Google Maps or Waze — whatever the user has installed — so turn-by-turn stays with the app they already trust. - Search places. Find an origin or destination by typing an address or a business name, and get the address of a coordinate. On iOS it runs on the device with MapKit, free; on Android through your provider, with the built-in geocoder as a fallback.
How it works
composer require guppylab/routing. The key from your purchase email unlocks the private repository; bought on the NativePHP marketplace, your NativePHP credentials do.
Directions::distances() with one origin and many destinations. On iPhone, MapKit answers on the device; on Android, the provider you configured.
DistancesReceived brings meters and seconds per destination. Sort the list, show the ETA, then navigate() hands the pick to Maps or Waze.
Where it fits
- Delivery and pickupThe nearest store by real driving time, not by a straight line across a river.
- Field serviceWhich technician or driver gets to the customer first.
- Real estate and travelHow long to work, to school or to the beach, by car, on foot or by transit.
- MarketplacesSellers and pickup points ordered by how long they take to reach.
How it looks
use Guppylab\Directions\Facades\Directions;
use Guppylab\Directions\Events\DistancesReceived;
use Native\Mobile\Attributes\OnNative;
Directions::distances($lat, $lng, [
['id' => 1, 'lat' => -23.5614, 'lng' => -46.6559],
['id' => 2, 'lat' => -23.5880, 'lng' => -46.6820],
]);
#[OnNative(DistancesReceived::class)]
public function onDistances(string $results = '[]', ?string $id = null): void
{
$event = new DistancesReceived($results, $id);
if ($event->failed()) {
$this->useStraightLineEstimate();
return;
}
$this->etas = $event->routed(); // ['1' => ['meters' => 4312, 'seconds' => 780, …]]
}
Locations stay between you and the map
- On the device on iPhoneMapKit computes the routes on the phone. No key and no bill per request.
- Your provider on AndroidYour own key, or your own OSRM server. Switching is one line of config.
- Nothing reaches usThe plugin talks to Apple or to your provider, never to Guppylab.
- Source includedPHP, Swift and Kotlin, with every provider adapter in the open.
Platforms
| iOS | MapKit MKDirections, iOS 15+. On-device, no key, no quota, nothing to configure. |
|---|---|
| Android | API 21+, plus an account with one of the providers above. Requires INTERNET, which the plugin declares. |
| NativePHP Mobile | 3.x and 4.x |
Licence and delivery
- One-time payment of $49. No subscription.
- One legal entity, unlimited applications, distributed in compiled form.
- Installed with Composer from a private repository; credentials arrive with your purchase.
- Full source — PHP, Swift, Kotlin.
- Routing providers are billed by them and governed by their terms. Guppylab carries no quota and no credential on your behalf.
Already on NativePHP Ultra? Routing is also on the NativePHP Plugin Marketplace: $49, or $35 for Ultra subscribers.
Not sure it fits? Ask first: suporte@guppylab.com.br