Setting the file. One moment.
Skill 16 · Mapbox Style Patterns
Subchapter 16.4
references/delivery-logistics.mdMarkdown8 KBView on GitHub
Use case: Food delivery, package delivery, logistics tracking, on-demand services (DoorDash, Uber Eats, courier apps)
Visual requirements:
Recommended layers:
{
"layers": [
{
"id": "background",
"type": "background",
"paint": {
"background-color": "#fafafa"
}
},
{
"id": "water",
"type": "fill",
"source": "mapbox-streets",
"source-layer": "water",
Key features:
Load custom arrow icon:
// Load custom arrow icon for driver direction indicator
// Note: 'arrow' is not a standard Maki icon and must be loaded manually
map.on('load', () => {
map.loadImage('path/to/arrow-icon.png', (error, image) => {
if (error) throw error;
map.addImage('arrow', image);
});
});Real-time update pattern:
// Update driver location (call on GPS update)
map.getSource('driver-locations').setData({
type: 'FeatureCollection',
features: drivers.map((driver) => ({
type: 'Feature',
geometry: {
type: 'Point',
coordinates: driver.location
},
properties: {
id: driver.id,
status: driver.status,
bearing: driver.bearing,
eta: driver.eta
}
}))
});
// Animate route progress
function updateRouteProgress(completedCoordinates) {
map.getSource('route-progress').setData({
type: 'Feature',
geometry: {
type: 'LineString',
coordinates: completedCoordinates
}
});
}
// Pulse animation for active delivery
function pulseCustomerMarker() {
const duration = 2000;
const start = performance.now();
function animate(time) {
const elapsed = time - start;
const phase = (elapsed % duration) / duration;
// Update radius (12 to 24 pixels)
map.setPaintProperty('customer-pulse', 'circle-radius', 12 + phase * 12);
// Update opacity (fade from 0.3 to 0)
map.setPaintProperty('customer-pulse', 'circle-opacity', 0.3 * (1 - phase));
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
}Performance tips:
setData() instead of removing/re-adding sources