1// Paramètres par défaut 2var default_lat = 48.8017689; 3var default_long = 2.151921; 4var default_zoom = 14; 5var default_type = 'ROADMAP'; 6 7// Au chargement 8window.addEventListener("load",function(event) { 9 10 // Jquery ? 11 if(window.jQuery) { loadApiScript(); } 12 else { alert("La librairie JQuery n'est pas chargée."); } 13}); 14 15// Chargement du script API 16function loadApiScript() { 17 18 let script = document.createElement('script'); 19 20 script.type = 'text/javascript'; 21 script.src = 'modules/carte/assets/js/leaflet/leaflet.js'; 22 23 document.body.appendChild(script); 24 25 script.addEventListener("load", () => { 26 loadMap(); 27 }); 28} 29 30// Chargement des cartes 31function loadMap() { 32 33 $('.load-carte').each(function() { 34 35 var id = $(this).data('id'); 36 var zoom = $(this).data('zoom'); 37 38 var module_path = $(this).data('modulepath'); 39 if(module_path === undefined) { module_path = 'modules/carte/'; } 40 41 var markers = []; 42 43 if(zoom == '' || zoom === undefined) zoom = default_zoom; 44 45 // Création de la carte 46 var map = L.map('carte_' + id, { 47 scrollWheelZoom: false 48 }).setView([default_lat, default_long], zoom); 49 50 L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { 51 attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', 52 minZoom: 1, 53 maxNativeZoom: 19, 54 maxZoom: 20 55 }).addTo(map); 56 57 // ===== ICONE PERSO ===== 58 var spotIcon = L.icon({ 59 iconUrl: module_path + 'assets/images/mapspot.png', 60 iconSize: [64, 64], 61 iconAnchor: [32, 64], 62 popupAnchor:[0, -64], 63 className: 'awt-spot' 64 }); 65 66 // Création des markers 67 $.ajax({ 68 type: "post", 69 url: "modules/carte/front/_ajax_get-adresses.php", 70 data: "id=" + id, 71 dataType: "json", 72 success: function(adresses){ 73 74 console.log(adresses); 75 76 var nb_marker = adresses.length; 77 78 $.each(adresses, function(i, adresse) { 79 80 if(adresse.latitude != 0 && adresse.longitude != 0) { 81 82 // Création du marker 83 //var marker = L.marker([adresse.latitude, adresse.longitude]).addTo(map); 84 var marker = L.marker([adresse.latitude, adresse.longitude], { icon: spotIcon }).addTo(map); 85 86 // Création de la Modal 87 let html; 88 89 html = '<div class="carte-adresse-modal">'; 90 // image 91 if(adresse.image !== null && adresse.image !== '') { 92 html += ' <img src="' + adresse.image + '" alt="' + adresse.titre + '" class="carte-adresse-modal-img">'; 93 } 94 html += ' <h2>' + adresse.titre + '</h2>'; 95 //html += ' <p>' + adresse.description + '</p>'; // <=== si pas de WYSIWYG 96 html += ' ' + adresse.description; // <=== si WYSIWYG 97 html += '</div>'; 98 99 marker.bindPopup(html); 100 101 // Ajout à la liste des markers pour la gestion du zoom automatique 102 markers.push(marker); 103 } 104 }); 105 106 // Ajustement automatique du Zoom 107 if(adresses.length > 1) { 108 109 var group = new L.featureGroup(markers); 110 map.fitBounds(group.getBounds().pad(0.5)); 111 } 112 else if(adresses.length == 1) { 113
114 map.setView([adresses[0].latitude, adresses[0].longitude], zoom); 115 } 116 }, 117 error: function(){ console.log('Erreur de chargement de la carte #' + id); } 118 }); 119 }); 120}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.