diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index cd4ebd30..09178566 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -14,6 +14,6 @@ class Authenticate extends Middleware */ protected function redirectTo(Request $request): ?string { - return $request->expectsJson() ? null : route('login'); + return $request->expectsJson() ? null : route('auth.login'); } } diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index a03d39cb..930aad3c 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -6,6 +6,7 @@ use App\Http\Resources\UserResource; use App\Models\User; +use App\Services\Nominatim; use Illuminate\Http\Request; use Inertia\Middleware; @@ -32,6 +33,7 @@ protected function shareOnce(Request $request): array return [ 'recaptcha_site_key' => config('recaptcha.api_site_key'), + 'max_map_bounds' => Nominatim::make()->maxBounds(), ]; } diff --git a/app/Services/Nominatim.php b/app/Services/Nominatim.php index 503bed1b..c29a4498 100644 --- a/app/Services/Nominatim.php +++ b/app/Services/Nominatim.php @@ -6,6 +6,7 @@ use App\DataTransferObjects\Location; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Cache; use NominatimLaravel\Content\Nominatim as NominatimClient; class Nominatim @@ -79,4 +80,29 @@ public function reverse(float $latitude, float $longitude): Location return new Location($result); } + + public function maxBounds(): array + { + return Cache::remember('max-map-bounds', now()->addDay(), function () { + $request = $this->nominatim->newSearch() + ->country('ro') + ->format('jsonv2'); + + $bounds = collect(rescue(fn () => $this->nominatim->find($request))) + ->filter(fn (array $result) => $result['place_rank'] === 4) + ->take(1) + ->pluck('boundingbox') + ->flatten() + ->map('floatval'); + + if ($bounds->count() !== 4) { + return null; + } + + return [ + [$bounds[0], $bounds[2]], + [$bounds[1], $bounds[3]], + ]; + }); + } } diff --git a/resources/js/Components/AddPointSteps/Location.vue b/resources/js/Components/AddPointSteps/Location.vue index 2d8ecc5f..f9bc99fa 100644 --- a/resources/js/Components/AddPointSteps/Location.vue +++ b/resources/js/Components/AddPointSteps/Location.vue @@ -10,6 +10,8 @@ ref="map" :zoom="18" :center="[form.location.lat, form.location.lng]" + :max-bounds="maxBounds" + :max-bounds-viscosity="1.0" @ready="ready" :options="{ attributionControl: false, @@ -36,21 +38,12 @@ - diff --git a/resources/js/Layouts/DashboardLayout.vue b/resources/js/Layouts/DashboardLayout.vue deleted file mode 100644 index 6960ecd5..00000000 --- a/resources/js/Layouts/DashboardLayout.vue +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/resources/js/Layouts/DefaultLayout.vue b/resources/js/Layouts/DefaultLayout.vue index bcddbe1e..faf7f1fc 100644 --- a/resources/js/Layouts/DefaultLayout.vue +++ b/resources/js/Layouts/DefaultLayout.vue @@ -1,5 +1,11 @@