Fix map views for gonoware/laravel-maps compatibility

- Add @push('styles') with @mapstyles to map views
- Fix markers parameter format (pass as 'markers' array, not string)
- Add null checks for location data
- Add @stack('styles') to layout for conditional style loading

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-19 02:33:22 +00:00
parent f37cb0b20b
commit 09a37c08a3
4 changed files with 51 additions and 42 deletions

View File

@@ -1,5 +1,9 @@
@extends('layouts.app')
@push('styles')
@mapstyles
@endpush
@section('content')
@if (Auth::user()->role_id >= 5)
<div class="container-fluid" style="height:100%">
@@ -33,28 +37,27 @@
</div>
@php
$markers=array();
$mapMarkers = [];
foreach ($currentcontracts as $currentcontract) {
$markers[] =
[
'title' => $currentcontract->id,
'lat' => $currentcontract->location->getLat(),
'lng' => $currentcontract->location->getLng(),
'popup' => '<h3>' . $currentcontract->id . '</h3><p>' . $currentcontract->address .
'<br>' . $currentcontract->suppliers->company_name ?? null . '<br>' . ucfirst($currentcontract->categories->name ?? null) .
'<br>' . $currentcontract->appointment . '<br>$' . $currentcontract->amount . '<br>' . ucfirst($currentcontract->status->name) .
'<br>' . $currentcontract->score . ' de 5</p>',
];
if ($currentcontract->location) {
$mapMarkers[] = [
'title' => $currentcontract->id,
'lat' => $currentcontract->location->getLat(),
'lng' => $currentcontract->location->getLng(),
'popup' => '<h3>' . $currentcontract->id . '</h3><p>' . $currentcontract->address .
'<br>' . ($currentcontract->suppliers->company_name ?? '') . '<br>' . ucfirst($currentcontract->categories->name ?? '') .
'<br>' . $currentcontract->appointment . '<br>$' . $currentcontract->amount . '<br>' . ucfirst($currentcontract->status->name ?? '') .
'<br>' . $currentcontract->score . ' de 5</p>',
];
}
}
$markers_json = str_replace(":", " => " ,str_replace("}", "]", str_replace("{", "[", json_encode($markers))));
@endphp
@map([
'lat' => 20.659698,
'lng' => -103.349609,
'zoom' => 12,
$markers_json
'markers' => $mapMarkers
])
<ul class="pagination">

View File

@@ -1,5 +1,9 @@
@extends('layouts.app')
@push('styles')
@mapstyles
@endpush
@section('content')
@if (Auth::user()->role_id >= 5)
<div class="container-fluid" style="height:100%">
@@ -33,28 +37,27 @@
</div>
@php
$markers=array();
$mapMarkers = [];
foreach ($finishedcontracts as $finishedcontract) {
$markers[] =
[
'title' => $finishedcontract->id,
'lat' => $finishedcontract->location->getLat(),
'lng' => $finishedcontract->location->getLng(),
'popup' => '<h3>' . $finishedcontract->id . '</h3><p>' . $finishedcontract->address .
'<br>' . $finishedcontract->suppliers->company_name ?? null . '<br>' . ucfirst($finishedcontract->categories->name ?? null) .
'<br>' . $finishedcontract->appointment . '<br>$' . $finishedcontract->amount . '<br>' . ucfirst($finishedcontract->status->name) .
'<br>' . $finishedcontract->score . ' de 5</p>',
];
if ($finishedcontract->location) {
$mapMarkers[] = [
'title' => $finishedcontract->id,
'lat' => $finishedcontract->location->getLat(),
'lng' => $finishedcontract->location->getLng(),
'popup' => '<h3>' . $finishedcontract->id . '</h3><p>' . $finishedcontract->address .
'<br>' . ($finishedcontract->suppliers->company_name ?? '') . '<br>' . ucfirst($finishedcontract->categories->name ?? '') .
'<br>' . $finishedcontract->appointment . '<br>$' . $finishedcontract->amount . '<br>' . ucfirst($finishedcontract->status->name ?? '') .
'<br>' . $finishedcontract->score . ' de 5</p>',
];
}
}
$markers_json = str_replace(":", " => " ,str_replace("}", "]", str_replace("{", "[", json_encode($markers))));
@endphp
@map([
'lat' => 20.659698,
'lng' => -103.349609,
'zoom' => 12,
$markers_json
'markers' => $mapMarkers
])
<ul class="pagination">

View File

@@ -21,7 +21,7 @@
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<link href="{{ asset('css/bootstrap-tagsinput.css') }}" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
@mapstyles
@stack('styles')
</head>
<body>
<div id="app" style="height: 100%">

View File

@@ -1,5 +1,9 @@
@extends('layouts.app')
@push('styles')
@mapstyles
@endpush
@section('content')
@if (Auth::user()->role_id >= 5)
<div class="container-fluid" style="height:100%">
@@ -32,27 +36,26 @@
</div>
</div>
@php
$markers=array();
$mapMarkers = [];
foreach ($postulations as $postulation) {
$markers[] =
[
'title' => $postulation->id,
'lat' => $postulation->location->getLat(),
'lng' => $postulation->location->getLng(),
'popup' => '<h3>' . $postulation->id . '</h3><p>' . $postulation->address .
'<br>' . ucfirst($postulation->categories->name ?? null) .
'<br>' . $postulation->appointment . '<br>' . $postulation->amount . '</p>',
];
if ($postulation->location) {
$mapMarkers[] = [
'title' => $postulation->id,
'lat' => $postulation->location->getLat(),
'lng' => $postulation->location->getLng(),
'popup' => '<h3>' . $postulation->id . '</h3><p>' . $postulation->address .
'<br>' . ucfirst($postulation->categories->name ?? '') .
'<br>' . $postulation->appointment . '<br>' . $postulation->amount . '</p>',
];
}
}
$markers_json = str_replace(":", " => " ,str_replace("}", "]", str_replace("{", "[", json_encode($markers))));
@endphp
@map([
'lat' => 20.659698,
'lng' => -103.349609,
'zoom' => 12,
$markers_json
'markers' => $mapMarkers
])
<ul class="pagination">