Subversion Repositories eFlore/Applications.coel

Compare Revisions

Ignore whitespace Rev 1821 → Rev 1822

/trunk/widget/modules/carto/squelettes/scripts/carto.js
150,9 → 150,11
if ((structures[index].longitude != null && structures[index].longitude != "")
&& (structures[index].latitude != null && structures[index].latitude != "")) {
var existeMarqueur = rechercherExistenceMarqueur(structures[index].longitude, structures[index].latitude);
if (!existeMarqueur) {
if (existeMarqueur == null) {
creerMarqueur(structures[index]);
nombreStructuresAffichees ++;
} else {
ajouterStructureAMarqueur(existeMarqueur, structures[index]);
}
}
}
162,10 → 164,10
}
 
function rechercherExistenceMarqueur(longitude, latitude) {
var existeMarqueur = false;
var existeMarqueur = null;
coucheStructures.eachLayer(function(layer) {
if (layer.getLatLng().lat == latitude && layer.getLatLng().lng == longitude) {
existeMarqueur = true;
existeMarqueur = layer;
}
});
return existeMarqueur;
174,34 → 176,33
function creerMarqueur(structure) {
var latlng = new L.LatLng(structure.latitude, structure.longitude);
var marqueur = new L.Marker(latlng, {
title : structure.nom
title : structure.nom,
structures : [structure]
});
marqueur.on('click', surClickMarqueur);
coucheStructures.addLayer(marqueur);
}
 
function ajouterStructureAMarqueur(marqueur, structure) {
marqueur.options.structures.push(structure);
// changer la propriété title du marqueur ne fonctionne pas
// en dehors du constructeur (mais cette méthode est-elle pérenne ?)
marqueur._icon.title += "\n"+structure.nom;
console.log(marqueur._icon);
}
 
function surClickMarqueur(event) {
var latlng = event.target.getLatLng();
var collections = new Array();
var structure = null;
for (var index = 0; index < structures.length; index ++) {
if (structures[index].latitude == latlng.lat && structures[index].longitude == latlng.lng) {
collections = collections.concat(structures[index].collections);
structure = structures[index];
afficherCollections(structure, collections);
break;
}
}
var structures = event.target.options.structures;
afficherCollections(structures, latlng);
}
 
function afficherCollections(structure, collections) {
function afficherCollections(structures, latlng) {
masquerInfoBulle();
infoBulle = new L.Popup({maxWidth : 0.25*$(window).width(), maxHeight : 0.35*$(window).height()});
var latlng = new L.LatLng(structure.latitude, structure.longitude);
infoBulle.setLatLng(latlng);
infoBulle.openOn(map);
remplirContenuPopup(structure, collections);
remplirContenuPopup(structures);
$("a").css("color", "#598000");
map.setView(latlng, map.getZoom());
}
213,16 → 214,25
infoBulle = null;
}
 
function remplirContenuPopup(structure, collections) {
function remplirContenuPopup(structures) {
$("#structure").empty();
var structureAjout = {
"id" : structure.id,
"nom" : structure.nom,
"ville" : structure.ville,
"code_postal" : structure.code_postal,
"collections" : collections
};
$("#tpl-structure").tmpl(structureAjout).appendTo($("#structure"));
var entetePopup = {
"ville" : structures[0].ville,
"code_postal" : structures[0].code_postal
}
$("#tpl-structure-entete").tmpl(entetePopup).appendTo($("#structure"));
$.each(structures, function(index, structure) {
var structureAjout = {
"id" : structure.id,
"nom" : structure.nom,
"ville" : structure.ville,
"code_postal" : structure.code_postal,
"collections" : structure.collections
};
$("#tpl-structure").tmpl(structureAjout).appendTo($("#structure"));
});
infoBulle.setContent($("#structure").html());
}
 
/trunk/widget/modules/carto/squelettes/carto.tpl.html
43,14 → 43,16
<div id="map"></div>
<!-- Squelette du contenu de la popup -->
<script id="tpl-structure-entete" type="text/x-jquery-tmpl">
<div class="popup-simple-text">Situé dans ${ville} (${code_postal})</div>
</script>
<script id="tpl-structure" type="text/x-jquery-tmpl">
<div id="description-structure">
<div class="description-structure">
<h3 align="center">
<a target="_blank" href="<?=$url_page_fiche?>?module=FicheStructure&id=${id}">${nom}</a>
</h3>
<div class="popup-simple-text">Situé dans ${ville} (${code_postal})</div>
<hr />
<div id="collections">
</h3>
<div class="collections">
{{if collections.length > 0}}
<div class="popup-simple-text">Collections présentes :</div>
<ul>
64,6 → 66,7
<div class="popup-simple-text">Aucune Collection d'herbiers recensée à ce jour</div>
{{/if}}
</div>
<hr />
</div>
</script>
<div id="structure" style="display:none"></div>