1. Go to this page and download the library: Download nwn-software/maplibre library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Filament\App\Widgets;
use App\Models\Employee;
use App\Models\User;
use NWNSoftware\Maplibre\Data\MarkerData;
use NWNSoftware\Maplibre\Widgets\MapLibreWidget;
class MapWidget extends MapLibreWidget {
protected array $center = [0, 0];
protected int $zoom = 9;
protected bool $allowFullscreen = true;
public function getMarkers(): array {
return [];
}
}
namespace App\Filament\App\Widgets;
use App\Models\Employee;
use App\Models\User;
use NWNSoftware\Maplibre\Data\MarkerData;
use NWNSoftware\Maplibre\Widgets\MapLibreWidget;
class MapWidget extends MapLibreWidget {
protected array $center = [0, 0];
protected int $zoom = 9;
protected bool $allowFullscreen = true;
public function getMarkers(): array {
return collect($devicePositions)->map(function ($devicePosition) {
return MarkerData::make()
->id($employee->id)
->longitude($devicePosition['Position'][0])
->latitude($devicePosition['Position'][1])
->toArray();
})->all();
}
}