Carte : remplace Leaflet CDN par bundle Vite local
Le CDN unpkg.com échoue si le serveur n'a pas accès à Internet. - npm install leaflet - resources/js/carte.js : point d'entrée qui importe Leaflet + expose window.LeafletMap - vite.config.js : ajoute carte.js aux inputs compilés - carte/index.blade.php : @vite au lieu du CDN, utilise window.LeafletMap Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,9 +7,8 @@
|
||||
</x-slot>
|
||||
|
||||
@push('head')
|
||||
{{-- Leaflet CSS --}}
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
|
||||
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="">
|
||||
{{-- Leaflet (bundlé via Vite) --}}
|
||||
@vite('resources/js/carte.js')
|
||||
<style>
|
||||
#carte-map {
|
||||
height: calc(100vh - 120px);
|
||||
@@ -45,13 +44,11 @@
|
||||
<div id="carte-map" class="w-full"></div>
|
||||
|
||||
@push('head')
|
||||
{{-- Leaflet JS (chargé en fin de head pour ne pas bloquer le rendu) --}}
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
|
||||
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV/XN2GqM8=" crossorigin=""
|
||||
defer></script>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const L = window.LeafletMap;
|
||||
if (!L) return;
|
||||
|
||||
// ── Initialisation de la carte ──────────────────────────────────────
|
||||
const map = L.map('carte-map', {
|
||||
center: [46.5, 2.2], // centre de la France
|
||||
|
||||
Reference in New Issue
Block a user