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:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user