Plan a technician's day from the overdue customers on a map, in Filament
A maintenance company services air conditioning and boilers for about 1,500 customers in London. Each contract says how often: every 30 days for some, every 90 for others. The dispatcher's question every Friday is the same: who is overdue, and who can go there on Monday? The customer table can be sorted by "last visit", but a sorted table does not show that six of the overdue customers are on the same three streets in Marylebone.
This article answers that question with Warp Map: the customers on a map, coloured by when their next visit is due, a selection drawn around one neighbourhood, a route for a technician's Monday, and the best order worked out with the arrival time at each stop. All pictures are from the live demo.
The scene: only the overdue customers
The map page shows every customer and lead. Under Visits due, the dispatcher keeps only Overdue: 233 customers turn red, and the rest disappear.
Step 1: put your model on the map
The customers are an ordinary Eloquent model with latitude and longitude columns. HasLocation and a mapLocation() tell Warp Map how to show them. This is the demo's customer, slightly shortened:
use Qalainau\FilamentWarpMap\Concerns\HasLocation;
use Qalainau\FilamentWarpMap\MapLocation;
class Customer extends Model
{
use HasLocation;
public static function mapLocation(): MapLocation
{
return MapLocation::make()
->latitude('lat')
->longitude('lng')
->address(fn (Customer $record) => "{$record->street}, {$record->city} {$record->postcode}", ['street', 'city', 'postcode'])
->title('name')
// How long a service visit takes, and when the place is open
->visitMinutes(fn (Customer $record) => $record->service_minutes)
->visitWindow(fn (Customer $record) => $record->opens_at ? [$record->opens_at, $record->closes_at] : null)
// Serviced every 30 or 90 days: "due soon" starts 7 days before
->visitEvery('visit_every_days', soon: 7);
}
}
The plugin is registered with the models to show and the people who visit them:
FilamentWarpMapPlugin::make()
->locations([Customer::class, Lead::class])
->people(Technician::class, title: 'name', home: fn (Technician $t) => [$t->home_lat, $t->home_lng, $t->home_address], color: 'color')
The last visit comes from the routes themselves: when a technician marks a visit Done on their phone, the customer turns green. No column to keep up to date.
Step 2: draw around a neighbourhood
The dispatcher searches for one customer by name, Quay Care Home, then presses Select an area and draws around the streets near it. Ten overdue customers are selected and listed on the left.
Step 3: add them to Monday's route
Add to a route asks for the day and the person. Maya Patel has nothing on Monday yet.
The Routes page opens on Maya's Monday. The visits are in the order they were added, and the line crosses itself: 10 visits, 22 miles, back at 16:40.
Step 4: best order
Best order works out the order with the least driving that still reaches every customer within their opening hours. Being on time beats driving less: an order that is late somewhere never wins over one that is not.
Under the map, each visit has its arrival time, the time there and the opening hours, with a badge when Maya would have to wait for a place to open or would arrive too late.
The order is worked out in PHP, without an external service: about 50 visits take a second or two, and the same input always gives the same order. When Maya is happy with it, Confirm the route locks it, and she sees it on her phone in My route.
Other scenes
- Several technicians: Share between people shares a selection between several people for a day, as a proposal you can adopt or discard.
- Territories: draw or import the areas each technician covers, and try a new split in a plan before you use it.
- Sales visits: leads on the same map, filtered by stage.
- With Warp Scheduler: travel time between jobs on the schedule, and "order this day" from the calendar.
Limits worth knowing
- Distances are straight-line estimates until you set a routing service: your own OSRM server or Google. (The demo uses its own OSRM.)
- A place with an address but no position is not on the map until it is geocoded; the map says how many there are.
- The best order is very good but not proven to be the best possible. You can always drag a visit.
Try it
Open the map demo, keep only Overdue, press Select an area and draw around a few red dots. Add them to someone's route and press Best order. No sign-up, and the data is reset every hour.