Subversion Repositories eFlore/Applications.moissonnage

Compare Revisions

No changes between revisions

Ignore whitespace Rev 36 → Rev 37

/trunk/widget/modules/carto/Carto.php
88,6 → 88,7
$widget['donnees']['communeImageUrl'] = $this->config['carto']['communeImageUrl'];
$widget['donnees']['pointImageUrl'] = $this->config['carto']['pointImageUrl'];
$widget['donnees']['clusterImageUrl'] = $this->config['carto']['clusterImageUrl'];
$widget['donnees']['liensVersSources'] = $this->config['carto']['liensVersSources'];
$widget['donnees']['listeSources'] = $this->config['carto']['sourcesDispo'];
$widget['donnees']['nomListeSources'] = $this->config['carto']['nomSourcesDispo'];
/trunk/widget/modules/carto/squelettes/carto.tpl.html
13,9 → 13,11
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css" />
<link rel="stylesheet" href="<?=$url_base?>modules/carto/squelettes/css/L.Control.Zoomslider.css" />
<link rel="stylesheet" href="<?=$url_base?>modules/carto/squelettes/css/MarkerCluster.Default.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.ie.css" />
<link rel="stylesheet" href="<?=$url_base?>modules/carto/squelettes/css/L.Control.Zoomslider.ie.css" />
<link rel="stylesheet" href="<?=$url_base?>modules/carto/squelettes/css/MarkerCluster.Default.ie.css" />
<![endif]-->
<link rel="stylesheet" href="http://www.tela-botanica.org/commun/jquery/fancybox/1.3.4/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
<link rel="stylesheet" href="http://www.tela-botanica.org/commun/jquery/jquery-ui/1.8.15/css/smoothness/jquery-ui-1.8.15.custom.css" type="text/css" media="screen" />
26,6 → 28,7
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/1.6.2/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/tablesorter/2.0.5/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/jquery-ui/1.8.15/js/jquery-ui-1.8.15.custom.min.js"></script>
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/pagination/2.2/jquery.pagination.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script type="text/javascript">
//<![CDATA[
45,8 → 48,9
var urlBase = '<?= $url_serivce_carto ?>/projets/';
var urlsLimitesCommunales = <?= $urlLimitesCommunales ?>;
var communeImageUrl = '<?= $communeImageUrl ?>';
var pointImageUrl = '<?= $pointImageUrl ?>';
var communeImageUrl = '<?= $communeImageUrl ?>';
var pointImageUrl = '<?= $pointImageUrl ?>';
var clusterImageUrl = '<?= $clusterImageUrl ?>';
var liensVersSources = '<?= $liensVersSources ?>'.split(',');
var titreLegende = '<?= $titreLegende ?>';
var listeSources = '<?= $listeSources ?>'.split(',');
59,6 → 63,7
<script src="<?=$url_base?>modules/carto/squelettes/scripts/L.KML.js" type="text/javascript"></script>
<script src="<?=$url_base?>modules/carto/squelettes/scripts/carto.js"></script>
<script src="<?=$url_base?>modules/carto/squelettes/scripts/L.Control.Zoomslider.js" ></script>
<script src="<?=$url_base?>modules/carto/squelettes/scripts/cluster.js" ></script>
</head>
 
<body>
108,15 → 113,9
<div id="info-bulle" style="width:{largeur}px;">
<div id="obs">
<h2 id="obs-station-titre">Station</h2>
<div class="navigation">&nbsp;</div>
<div>
<ul>
<li><a href="#obs-vue-tableau">Tableau</a></li>
<li><a href="#obs-vue-liste">Liste</a></li>
</ul>
</div>
<div class="navigation">&nbsp;</div>
<div id="observations">
<div id="obs-vue-tableau" style="display:none;">
<div id="obs-vue-tableau">
<table id="obs-tableau">
<thead>
<tr>
124,6 → 123,7
<th title="Date de l'observation">Date</th>
<th title="Lieu d'observation">Lieu</th>
<th title="Auteur de l'observation">Observateur</th>
<th title="Nom du projet référent">Projet</th>
</tr>
</thead>
<tbody id="obs-tableau-lignes" class="obs-conteneur">
131,16 → 131,10
</tbody>
</table>
</div>
<div id="obs-vue-liste" style="display:none;">
<ol id="obs-liste-lignes" class="obs-conteneur">
<!-- Insertion des lignes à partir du squelette tpl-obs-liste -->
</ol>
</div>
</div>
<div id="obs-pieds-page">
<p>Id : <span id="obs-station-id">&nbsp;</span></p>
</div>
<div class="navigation">&nbsp;</div>
</div>
</div>
</script>
177,72 → 171,10
&nbsp;
{{/if}}
</td>
<td><span>${projet}</span></td>
</tr>
</script>
<!-- Squelette du contenu de la liste des observations -->
<script id="tpl-obs-liste" type="text/x-jquery-tmpl">
<li>
<div class="cel-obs-${idObs}">
{{if images}}
{{each(index, img) images}}
<div{{if index == 0}} class="cel-img-principale" {{else}} class="cel-img-secondaire"{{/if}}>
<a class="cel-img"
href="${img.normale}"
title="${nomSci} {{if nn}} [${nn}] {{/if}} par ${observateur} - Publiée le ${datePubli} - GUID : ${img.guid}"
rel="cel-obs-${idObs}">
<img src="${img.miniature}" alt="Image #${img.idImg} de l'osbervation #${nn}" />
</a>
<p id="cel-info-${img.idImg}" class="cel-infos">
<a class="cel-img-titre" href="${urlEflore}"
onclick="window.open(this.href);return false;"
title="Cliquez pour accéder à la fiche eFlore">
<strong>${nomSci} {{if nn}} [nn${nn}] {{/if}}</strong> par <em>${observateur}</em>
</a>
<br />
<span class="cel-img-date">Publiée le ${datePubli}</span>
</p>
</div>
{{/each}}
{{/if}}
<dl>
<dt class="champ-nom-sci">Nom</dt>
<dd title="Nom défini par l'utilisateur{{if nn != 0}}. Cliquez pour accéder à la fiche d'eFlore.{{/if}}">
<span class="nom-sci">&nbsp;
{{if nn != 0}}
<a href="http://www.tela-botanica.org/nn${nn}"
target="_blank">
${nomSci}
</a>
{{else}}
${nomSci}
{{/if}}
</span>
</dd>
<dt title="Lieu d'observation">Lieu</dt><dd class="lieu">&nbsp;${lieu}</dd>
<dt title="Date d'observation">Le</dt><dd class="date">&nbsp;${date}</dd>
<dt title="Auteur de l'observation">Publié par</dt>
<dd>
{{if observateur}}
{{if observateurId}}
<a class="contact obs-${idObs} contributeur-${observateurId}"
href="#form-contact"
title="Contactez ce contributeur">
${observateur}
</a>
{{else}}
${observateur}
{{/if}}
{{else}}
&nbsp;
{{/if}}
</dd>
</dl>
<hr class="nettoyage"/>
</div>
</li>
</script>
<!-- Squelette de la liste des taxons -->
<script id="tpl-taxons-liste" type="text/x-jquery-tmpl">
<ol id="taxons">
255,5 → 187,6
{{/each}}
</ol>
</script>
<div id="tooltip" style="display:none;"></div>
</body>
</html>
/trunk/widget/modules/carto/squelettes/images/trie_croissant.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
/trunk/widget/modules/carto/squelettes/images/trie_decroissant.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
/trunk/widget/modules/carto/squelettes/images/trie.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
/trunk/widget/modules/carto/squelettes/scripts/layer/Marker.Rotate.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/layer/Icon.Canvas.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/layer/tile/Yandex.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/layer/tile/Google.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/layer/tile/Bing.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/layer/Marker.Text.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/layer/vector/KML.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/layer/vector/GPX.Speed.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/layer/vector/GPX.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/layer/vector/OSM.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/layer/OpenStreetBugs.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/layer/Layer.Deferred.js
File deleted
/trunk/widget/modules/carto/squelettes/scripts/carto.js
1,62 → 1,3
// Javascript Document
 
 
// ===================================================================================
// FONCTIONS ADDITIONNELLES POUR GERER LES URLS ET L'OUVERTRURE DE NOUVELLE FENETRE
function convertirEnParametresUrl(objet) {
var parametresUrl = '';
for (attribut in objet) {
if (typeof(objet[attribut]) == 'function' || typeof(objet[attribut]) == 'undefined' ||
objet[attribut] == null || objet[attribut] == '*' || objet[attribut] == 0)
continue;
parametresUrl += (parametresUrl == '' ? '' : '&') + attribut + "=" + objet[attribut];
}
return parametresUrl;
};
 
function recupererParametreDansUrl(nomParametre, chaineRecherche) {
var split = chaineRecherche.split('?');
chaineRecherche = split[split.length-1];
var valeurParametre = null;
var listeParametres = chaineRecherche.split("&");
for (var index = 0; index < listeParametres.length; index ++) {
var split = listeParametres[index].split("=");
if (split[0] == nomParametre) {
valeurParametre = split[1];
break;
}
}
return valeurParametre;
};
 
function estValeurDansTableau(tableau, valeur) {
var index;
for (index = 0; index < tableau.length && tableau[index] != valeur; index ++);
return (tableau.length > 0 && index != tableau.length);
}
 
function ouvrirNouvelleFenetre(element, event) {
window.open(element.href);
return arreter(event);
}
 
function arreter(event) {
if (event.stopPropagation) {
event.stopPropagation();
} else if (window.event) {
window.event.cancelBubble = true;
}
if (event.preventDefault) {
event.preventDefault();
}
event.returnValue = false;
return false;
}
 
 
 
// =============================================================
 
var map = null,
optionsCoucheOSM = {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors,'
67,12 → 8,12
attribution: 'Map data &copy;'+new Date().getFullYear()+' <a href="http://maps.google.com">Google</a>',
maxZoom: 18
},
coucheOSM = new L.TileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
coucheOSM = new L.TileLayer("http://a.tile.openstreetmap.org/{z}/{x}/{y}.png",
optionsCoucheOSM),
couchePlanGoogle = new L.TileLayer("http://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
coucheRelief = new L.TileLayer("http://c.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png",
optionsCoucheOSM),
coucheSatellite = new L.TileLayer("http://mt1.google.com/vt/lyrs=y@218131653&hl=fr&src=app&x={x}&y={y}&z={z}",
optionsCoucheGoogle),
coucheSatelliteGoogle = new L.TileLayer("http://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}",
optionsCoucheGoogle),
optionsCarte = {
center : new L.LatLng(46, 2),
zoom : 6,
85,19 → 26,15
coucheDepartement = null,
infoBulle = null;
 
var coucheSites = new L.FeatureGroup(),
points = new Array(),
coucheSites = new L.FeatureGroup(),
var coucheSites = null,
sources = new Object(),
formeDonnees = '',
popupMaille = null;
typeSite = 'maille',
overlays = [];
 
var requeteChargementPoints = null,
chargementMaillesEnCours = false,
doitRafraichirCarte = true,
chargementCommunesEnCours = false,
timer = null,
ancienneRequete = null,
deplacement = true,
url = '';
 
 
107,50 → 44,27
initialiserWidget();
});
 
$(window).resize(function() {
dimensionnerCarte();
});
 
function initialiserWidget() {
initialiserCarte();
dimensionnerOverlay();
chargerLimitesCommunales();
initialiserPanneauControle();
initialiserSources();
initialiserListeners();
chargerLimitesCommunales();
chargerMaillesVides();
programmerRafraichissementCarte();
chargerLocalisations();
}
 
$(window).resize(function() {
dimensionnerCarte();
if (infoBulle != null) {
redimensionnerPopup();
}
});
 
function dimensionnerOverlay() {
var taille = '1.6';
var tailleMaxIcones = 20;
var padding_icones = 8;
$("#zone-titre h1").css('font-size', (taille)+'em');
$("#zone-titre").css('padding', padding_icones+"px "+padding_icones+"px "+Math.round(padding_icones/4)+"px");
$('#zone-titre').height(tailleMaxIcones*2);
var left = ($(window).width()-$('#zone-titre').width())/2;
$('#zone-titre').css('left',left);
}
 
 
function dimensionnerCarte() {
$('#map').height($(window).height());
$('#map').width($(window).width());
}
 
function initialiserCarte() {
dimensionnerCarte();
map = L.map('map', optionsCarte);
coucheSites.addTo(map);
coucheSatellite.addTo(map);
coucheRelief.addTo(map);
coucheOSM.addTo(map);
couchePlanGoogle.addTo(map);
coucheSatelliteGoogle.addTo(map);
var echelle = new L.Control.Scale({
maxWidth : 32,
maxWidth : 50,
metric : true,
imperial : false,
updateWhenIdle : true
159,9 → 73,14
zoom = map.getZoom();
}
 
function dimensionnerCarte() {
$('#map').height($(window).height());
$('#map').width($(window).width());
}
 
function initialiserListeners() {
map.on('moveend', surChangementVueSurCarte);
map.on('zoomend', surChangementVueSurCarte);
map.on('moveend', surChangementVueCarte);
map.on('zoomend', surChangementVueCarte);
map.on('popupclose', function(e) {
masquerInfoBulle();
programmerRafraichissementCarte();
170,9 → 89,9
 
function initialiserPanneauControle() {
var baseMaps = {
"OpenStreetMap" : coucheOSM,
"Plan" : couchePlanGoogle,
"Satellite" : coucheSatelliteGoogle
"Satellite" : coucheSatellite,
"Relief" : coucheRelief,
"Plan" : coucheOSM
};
 
var overlayMaps = {};
182,8 → 101,8
}
L.control.layers(baseMaps, overlayMaps).addTo(map);
coucheOSM.bringToFront();
couchePlanGoogle.bringToBack();
coucheSatelliteGoogle.bringToBack();
map.removeLayer(coucheRelief);
map.removeLayer(coucheOSM);
// garder par defaut la couche plan google comme selectionnee dans le panel
var selecteursFonds = $('.leaflet-control-layers-base .leaflet-control-layers-selector');
213,62 → 132,111
});
}
 
function determinerSourcesSelectionnees() {
var sourcesSelectionnees = new Array();
for (source in sources) {
if (sources[source] == true) {
sourcesSelectionnees.push(source);
function changerSource(projetClique) {
var indexProjetClique;
for (var index = 0; index < overlays.length; index ++) {
if (overlays[index].value == projetClique) {
indexProjetClique = index;
}
}
return sourcesSelectionnees;
masquerInfoBulle();
sources[projetClique] = overlays[indexProjetClique].checked;
if (sources[projetClique] == true) {
programmerRafraichissementCarte(projetClique);
} else {
if (requeteEnCours()) {
stopperRequeteAjax();
}
supprimerFeaturesSource(projetClique);
}
}
 
function surChangementVueSurCarte() {
if (doitRafraichirCarte == false) {
doitRafraichirCarte = true;
function supprimerFeaturesSource(source) {
if (coucheSites != null) {
coucheSites.eachLayer(function(layer) {
if (layer.typeSite == 'maille') {
retirerStationsEtObservations(layer, source);
} else {
layer.supprimerSource(source, coucheSites);
if (layer._map == 'null') {
couheSites.removeLayer(layer);
}
}
});
if (typeSite == 'maille') {
var nombreMailles = calculerNombreMaillesVisibles();
if (nombreMailles == 0) {
coucheSites.clearLayers();
masquerLegende();
typeSite = 'point';
}
}
}
}
 
function retirerStationsEtObservations(maille, sourceRetrait) {
var sources = maille.properties.source;
var nombreStations = 0;
for (var index = 0; index < sources.length; index ++) {
var source = sources[index];
if (source == sourceRetrait) {
delete maille.properties.stations[source];
delete maille.properties.observations[source];
} else if (typeof(maille.properties.stations[source]) != 'undefined') {
nombreStations += parseInt(maille.properties.stations[source]);
}
}
if (nombreStations == 0) {
coucheSites.removeLayer(maille);
} else {
supprimerTousLayers();
zoom = map.getZoom();
chargerMaillesVides();
colorerMaille(maille)
genererInfobulle(maille);
}
}
 
function chargerMaillesVides() {
chargementMaillesEnCours = true;
function calculerNombreMaillesVisibles() {
var nombreMailles = 0;
coucheSites.eachLayer(function(layer) {
if($(layer._path).attr('fill-opacity') != '0') {
nombreMailles ++;
}
});
return nombreMailles;
}
 
function estValeurDansTableau(tableau, valeur) {
var index;
for (index = 0; index < tableau.length && tableau[index] != valeur; index ++);
return (tableau.length > 0 && index != tableau.length);
}
 
//************************************
// requetes stations
 
function surChangementVueCarte() {
programmerRafraichissementCarte();
}
 
function programmerRafraichissementCarte(source) {
$('#tooltip').css('display', 'none');
source = (source == null || source == 'null') ? null : source;
if (timer != null) {
window.clearTimeout(timer);
}
window.clearTimeout(timer);
}
if (requeteChargementPoints != null) {
stopperRequeteAjax();
}
timer = window.setTimeout(function() {
var coordonneesBordure = calculerCoordonneesBordure();
var parametres = {
"source" : "floradata",
"bbox" : coordonneesBordure,
"zoom" : map.getZoom()
};
url = urlBase + "mailles?" + convertirEnParametresUrl(parametres);
fonctionCallback = traiterDonneesStations;
executerAJAX();
}, 400);
}
 
function programmerRafraichissementCarte(source) {
source = (source == null || source == 'null') ? null : source;
if (!chargementMaillesEnCours) {
if (timer != null) {
window.clearTimeout(timer);
var nombreSourcesVisibles = 0;
for (var index = 0; index < overlays.length; index ++) {
if (overlays[index].checked) {
nombreSourcesVisibles ++;
}
if (requeteChargementPoints != null) {
if (source == null) {
stopperRequeteAjax();
}
}
timer = window.setTimeout("rafraichirDonnnees('"+source+"')", 250);
} else {
window.setTimeout("programmerRafraichissementCarte('"+source+"')", 400);
}
}
if (source == null) {
timer = window.setTimeout("chargerLocalisations()", 100);
} else {
timer = window.setTimeout("chargerSource('"+source+"')", 100);
}
}
 
function stopperRequeteAjax() {
276,84 → 244,140
requeteChargementPoints = null;
}
 
function rafraichirDonnnees(source) {
source = (source == null || source == 'null') ? null : source;
if (coucheDepartement == null || coucheDepartement.getStatus() == KML_READY) {
if (source != null) {
chargerLocalisations(source);
} else {
supprimerLocalisations();
for (source in sources) {
if (sources[source] == true) {
chargerLocalisations(source);
}
}
}
} else {
window.setTimeout("rafraichirDonnnees('"+source+"')", 800);
function chargerLocalisations() {
if (requeteEnCours()) {
requeteChargementPoints.abort();
}
afficherMessageChargement('stations');
if (!(ancienneRequete != null && ancienneRequete[1] == map.getZoom()
&& map.getBounds().intersects(ancienneRequete[0]))) {
supprimerFeatures();
deplacement = false;
}
var bboxRequete = calculerBboxRequete();
var parametres = {
"bbox" : bboxRequete,
"zoom" : map.getZoom(),
"source" : recupererSourcesActivees(),
"num_taxon" : numTaxon,
"nn" : nn,
"referentiel" : referentiel,
"dept" : dept,
"auteur" : auteur,
"date_debut" : dateDebut,
"date_fin" : dateFin,
"nb_jours" : nbJours
};
if (deplacement == true) {
parametres.format = typeSite;
}
ancienneRequete = [map.getBounds(), map.getZoom()];
url = urlBase + "stations?" + convertirEnParametresUrl(parametres);
fonctionCallback = traiterDonneesStations;
executerAJAX();
}
 
function supprimerTousLayers() {
coucheSites.clearLayers();
points = [];
formeDonnees = '';
function supprimerFeatures() {
if (coucheSites != null) {
coucheSites.clearLayers();
coucheSites = null;
}
}
 
function supprimerLocalisations(source) {
source = (typeof(source) == 'undefined') ? null : source;
if (source != null) {
var sourceUrl = recupererParametreDansUrl('source', url);
if (requeteChargementPoints != null && sourceUrl == source && source != null) {
stopperRequeteAjax();
function recupererSourcesActivees(sourceAIgnorer) {
sourceAIgnorer = typeof(sourceAIgnorer) == 'undefined' ? '' : sourceAIgnorer;
var sourcesActivees = [];
for (var index = 0; index < overlays.length; index ++) {
if (overlays[index].checked == true && overlays[index].value != sourceAIgnorer) {
sourcesActivees.push(overlays[index].value);
}
coucheSites.eachLayer(function(layer) {
supprimerLayer(layer, source);
});
if (source != null) {
supprimerPointsListe(source);
}
var sourcesSelectionnees = determinerSourcesSelectionnees();
if (sourcesSelectionnees.length == 1 && determinerNombreMarqueurs(sourcesSelectionnees[0]) > 0) {
transformerMaillesEnPoints(sourcesSelectionnees[0]);
}
var sontPointsAffiches = (points.length>0 && determinerNombreMailles(false)==0);
formeDonnees = sontPointsAffiches ? 'point' : 'maille';
}
return sourcesActivees.join(',');
}
 
function estLayerUtilisePourSource(layer, source) {
return (
(layer.typeSite == 'MAILLE' && typeof(layer.nombrePoints[source]) != 'undefined') ||
(layer.typeSite != 'MAILLE' && layer.source == source)
);
function chargerSource(sourceAjout) {
if (requeteEnCours()) {
requeteChargementPoints.abort();
}
afficherMessageChargement('stations');
var bboxRequete = determinerCoordonneesBordure();
var parametres = {
"bbox" : bboxRequete,
"zoom" : map.getZoom(),
"format" : typeSite,
"source" : sourceAjout,
"num_taxon" : numTaxon,
"nn" : nn,
"referentiel" : referentiel,
"dept" : dept,
"auteur" : auteur,
"date_debut" : dateDebut,
"date_fin" : dateFin,
"nb_jours" : nbJours
};
ancienneRequete = [map.getBounds(), map.getZoom()];
url = urlBase + "stations?" + convertirEnParametresUrl(parametres);
fonctionCallback = traiterRetourChargementSource;
executerAJAX();
}
 
function supprimerLayer(layer, source) {
if (estLayerUtilisePourSource(layer, source)) {
if (layer.typeSite == 'MAILLE') {
supprimerSourceDansMaille(layer, source);
function calculerBboxRequete() {
var bordure = map.getBounds();
var bboxRequete = "";
if (ancienneRequete != null && ancienneRequete[1] == map.getZoom()
&& bordure.intersects(ancienneRequete[0])) {
bboxRequete = calculerIntersectionRectangle(ancienneRequete[0], bordure);
} else {
bboxRequete = determinerCoordonneesBordure();
}
return bboxRequete;
}
 
function calculerIntersectionRectangle(rectangle1, rectangle2) {
var bbox1 = [rectangle2.getSouthWest().lng.toFixed(6), rectangle2.getSouthWest().lat.toFixed(6),
rectangle2.getNorthEast().lng.toFixed(6), rectangle2.getNorthEast().lat.toFixed(6)];
var bbox2 = [rectangle2.getSouthWest().lng.toFixed(6), rectangle2.getSouthWest().lat.toFixed(6),
rectangle2.getNorthEast().lng.toFixed(6), rectangle2.getNorthEast().lat.toFixed(6)];
if (rectangle2.getSouthWest().lng >= rectangle1.getSouthWest().lng
&& rectangle2.getSouthWest().lng <= rectangle1.getNorthEast().lng) {
bbox2[0] = bbox1[2] = rectangle1.getNorthEast().lng.toFixed(6);
if (rectangle2.getSouthWest().lat >= rectangle1.getSouthWest().lat
&& rectangle2.getSouthWest().lat <= rectangle1.getNorthEast().lat) {
bbox1[1] = rectangle1.getNorthEast().lat.toFixed(6);
} else {
coucheSites.removeLayer(layer);
bbox1[3] = rectangle1.getSouthWest().lat.toFixed(6);
}
} else {
bbox2[0] = bbox1[2] = rectangle1.getSouthWest().lng.toFixed(6);
if (rectangle2.getSouthWest().lat >= rectangle1.getSouthWest().lat
&& rectangle2.getSouthWest().lat <= rectangle1.getNorthEast().lat) {
bbox2[1] = rectangle1.getNorthEast().lat.toFixed(6);
} else {
bbox2[3] = rectangle1.getSouthWest().lat.toFixed(6);
}
}
return bbox1.join(',')+'|'+bbox2.join(',');
}
 
 
function changerSource(projetClique) {
var indexProjetClique;
for (var index = 0; index < overlays.length; index ++) {
if (overlays[index].value == projetClique) {
indexProjetClique = index;
}
function determinerCoordonneesBordure() {
var ouest = map.getBounds().getSouthWest().lng.toFixed(6),
sud = Math.max(map.getBounds().getSouthWest().lat, -85.051129).toFixed(6),
est = map.getBounds().getNorthEast().lng.toFixed(6),
nord = Math.min(map.getBounds().getNorthEast().lat, 85.051129).toFixed(6);
// appliquer les limites possibles de la projection actuellement utilisee aux coordonnees
// longitudes ouest et est de la bbox (permettra d'eviter de renvoyer des messages d'erreur)
if (ouest < -180) {
ouest += 360;
} else if (ouest > 180) {
ouest -= 360;
}
masquerInfoBulle();
sources[projetClique] = overlays[indexProjetClique].checked;
if (sources[projetClique] == true) {
programmerRafraichissementCarte(projetClique);
} else {
supprimerLocalisations(projetClique);
if (est < -180) {
est += 360;
} else if (est > 180) {
est -= 360;
}
return [ouest, sud, est, nord].join(',');
}
 
function afficherMessageChargement(element) {
369,11 → 393,8
$("#zone-chargement").children().remove();
}
 
 
// execution d'une requete AJAX
function executerAJAX() {
if (requeteEnCours()) {
masquerMessageChargement();
requeteChargementPoints.abort();
}
requeteChargementPoints = $.getJSON(url).complete(function() {
390,54 → 411,36
|| requeteChargementPoints.status == 0);
}
 
function chargerLocalisations(source) {
if (requeteEnCours()) {
window.setTimeout("chargerLocalisations('"+source+"')", 400);
} else {
afficherMessageChargement('stations');
// generer l'URL du script a interroger sur le serveur
var coordonneesBordure = calculerCoordonneesBordure();
var parametres = {
"source" : source,
"num_taxon" : numTaxon,
"referentiel" : referentiel,
"dept" : dept,
"nn" : nn,
"auteur" : auteur,
"date_debut" : dateDebut,
"date_fin" : dateFin,
"bbox" : coordonneesBordure,
"nb_jours" : nbJours,
"zoom" : map.getZoom()
};
url = urlBase + "stations?" + convertirEnParametresUrl(parametres);
fonctionCallback = traiterDonneesStations;
executerAJAX();
function convertirEnParametresUrl(objet) {
var parametresUrl = '';
for (attribut in objet) {
if (typeof(objet[attribut]) == 'function' || typeof(objet[attribut]) == 'undefined' ||
objet[attribut] == null || objet[attribut] == '*' || objet[attribut] == 0)
continue;
parametresUrl += (parametresUrl == '' ? '' : '&') + attribut + "=" + objet[attribut];
}
}
return parametresUrl;
};
 
function calculerCoordonneesBordure() {
var bordure = map.getBounds();
var ouest = bordure.getSouthWest().lng.toFixed(6),
sud = Math.max(bordure.getSouthWest().lat, -85.051129).toFixed(6),
est = bordure.getNorthEast().lng.toFixed(6),
nord = Math.min(bordure.getNorthEast().lat, 85.051129).toFixed(6);
// appliquer les limites possibles de la projection actuellement utilisee aux coordonnees
// longitudes ouest et est de la bbox (permettra d'eviter de renvoyer des messages d'erreur)
if (ouest < -180) {
ouest += 360;
} else if (ouest > 180) {
ouest -= 360;
function traiterDonneesStations() {
masquerMessageChargement();
masquerLegende();
if (deplacement == true) {
supprimerFeaturesHorsBbox();
}
if (est < -180) {
est += 360;
} else if (est > 180) {
est -= 360;
deplacement = true;
var texte = requeteChargementPoints.responseText;
if (!estStatutRequeteOK()) {
alert(texte);
} else {
var donneesJSON = eval("(function(){return " + texte + ";})()");
if (donneesJSON != null && donneesJSON.features.length > 0) {
ajouterStationsSurCarte(donneesJSON);
}
}
return [ouest, sud, est, nord].join(',');
}
 
function traiterDonneesStations() {
function traiterRetourChargementSource() {
masquerMessageChargement();
var texte = requeteChargementPoints.responseText;
if (!estStatutRequeteOK()) {
444,82 → 447,78
alert(texte);
} else {
var donneesJSON = eval("(function(){return " + texte + ";})()");
if (donneesJSON != null && typeof(donneesJSON.features) != 'undefined') {
if (donneesJSON != null && donneesJSON.features.length > 0) {
var formatRetourDifferent = donneesJSON.stats.formeDonnees != typeSite;
ajouterStationsSurCarte(donneesJSON);
if (formatRetourDifferent) {
var sourceAIgnorer = donneesJSON.stats.source[0];
var sourcesARecharger = recupererSourcesActivees(sourceAIgnorer);
rechargerSources(sourcesARecharger);
}
}
}
}
 
function ajouterStationsSurCarte(data) {
if (doitTransformerEnMaille(data.stats)) {
if (points.length > 0 && data.stats.source != '') {
combinerMaillesEtPoints();
}
formeDonnees = 'maille';
} else {
formeDonnees = data.stats.formeDonnees;
function supprimerFeaturesHorsBbox() {
var bordure = map.getBounds();
var layersRestants = 0;
if (coucheSites != null) {
coucheSites.eachLayer(function(layer) {
if (typeof(layer._latlng) != 'undefined') {
if (bordure.contains(layer.getLatLng())) {
layersRestants ++;
} else {
coucheSites.supprimerPoint(layer);
}
} else {
if (bordure.intersects(layer.getBounds())) {
layersRestants ++;
} else {
coucheSites.removeLayer(layer);
}
}
});
}
var sourceDonnees = data.stats.source;
for (var index = 0; index < data.features.length; index ++) {
ajouterStation(data.features[index]);
if (layersRestants == 0) {
coucheSites = null;
}
if (formeDonnees == 'maille' && data.stats.sites > 0) {
afficherLegende();
regenererInfobulleMailles();
} else {
masquerLegende();
}
 
function rechargerSources(sourcesARecharger) {
var listeSourcesASupprimer = sourcesARecharger.split(',');
for (var index = 0; index < listeSourcesASupprimer.length; index ++) {
supprimerFeaturesSource(listeSourcesASupprimer[index]);
}
if (chargementMaillesEnCours) {
chargementMaillesEnCours = false;
programmerRafraichissementCarte();
}
chargerSource(sourcesARecharger);
}
 
function ajouterStation(feature) {
if (feature.properties.typeSite == 'MAILLE') {
traiterMaille(feature);
function ajouterStationsSurCarte(donnees) {
typeSite = donnees.stats.formeDonnees;
if (coucheSites == null) {
coucheSites = (typeSite == 'maille') ? new L.FeatureGroup() : new L.ClusterGroup();
map.addLayer(coucheSites);
}
for (var index = 0; index < donnees.features.length; index ++) {
var feature = donnees.features[index];
if (typeSite == 'maille') {
traiterMaille(feature);
} else {
ajouterPoint(feature);
}
}
if (donnees.features.length > 0) {
afficherLegende();
}
if (typeSite == 'maille') {
genererInfobulleMailles();
} else {
ajouterPoint(feature);
coucheSites.afficherClusters();
}
}
 
function doitTransformerEnMaille(statsFeatures) {
var condition1 = (formeDonnees == 'point' && statsFeatures.formeDonnees =='maille');
var condition2 = (formeDonnees == 'maille' && statsFeatures.formeDonnees =='point'
&& determinerNombreMailles(false) > 0);
var condition3 = (statsFeatures.formeDonnees == 'point' && map.getZoom() <= ZOOM_MAXIMUM_MAILLAGE
&& (points.length+statsFeatures.sites) > SEUIL_MAILLAGE);
return (condition1 || condition2 || condition3);
}
 
 
 
// ====================================================================
// =========================================
// Gestion des mailles
 
var optionsMaille = {
color: '#FFFFFF',
opacity : 0.7,
weight: 1,
fillOpacity : 0.6
};
 
function determinerNombreMailles(prendToutesMailles) {
var nombreMailles = 0;
coucheSites.eachLayer(function(layer) {
if ('typeSite' in layer && layer.typeSite == 'MAILLE') {
var nombrePoints = 0;
for (var source in layer.nombrePoints) {
nombrePoints = layer.nombrePoints[source];
}
if (prendToutesMailles || nombrePoints>0) {
nombreMailles ++;
}
}
});
return nombreMailles;
}
 
function traiterMaille(feature) {
var coordonnees = [];
for (var i = 0; i < feature.geometry.coordinates.length; i++) {
529,15 → 528,16
var maille = rechercherMailleExistante(coordonnees);
if (maille) {
mettreAJourMaille(maille, feature);
} else if (feature.properties.nombrePoints > 0) {
ajouterMaille(feature);
} else {
maille = ajouterMaille(feature, coordonnees);
}
colorerMaille(maille);
}
 
function rechercherMailleExistante(coordonnees) {
var mailleTrouvee = null;
coucheSites.eachLayer(function(layer) {
if ('typeSite' in layer && layer.typeSite == 'MAILLE') {
if ('typeSite' in layer && layer.typeSite == 'maille') {
if (sontMaillesIdentiques(coordonnees, layer._latlngs)) {
mailleTrouvee = layer;
return;
556,60 → 556,49
);
}
 
function ajouterMaille(feature) {
var coordonnees = [];
for (var i = 0; i < feature.geometry.coordinates.length; i++) {
var sommet = new L.LatLng(feature.geometry.coordinates[i][0], feature.geometry.coordinates[i][1]);
coordonnees.push(sommet);
}
function ajouterMaille(feature, coordonnees) {
var maille = new L.Polygon(coordonnees);
var optionsMaille = {
color: '#FFFFFF',
opacity : 0.7,
weight: 1,
fillOpacity : 0.6
};
maille.setStyle(optionsMaille);
maille.typeSite = feature.properties.typeSite;
maille.nombrePoints = new Object();
var nombreAAjouter = feature.properties.nombrePoints == null ? 0 : parseInt(feature.properties.nombrePoints);
maille.nombrePoints[feature.properties.source] = nombreAAjouter;
maille.typeSite = 'maille';
maille.properties = feature.properties;
coucheSites.addLayer(maille);
colorerMaille(maille);
return maille;
}
 
function mettreAJourMaille(maille, feature) {
var nombreAAjouter = feature.properties.nombrePoints == null ? 0 : parseInt(feature.properties.nombrePoints);
/*if (typeof(maille.nombrePoints[feature.properties.source]) == 'undefined') {
maille.nombrePoints[feature.properties.source] = nombreAAjouter;
} else {
maille.nombrePoints[feature.properties.source] += nombreAAjouter;
}*/
maille.nombrePoints[feature.properties.source] = nombreAAjouter;
colorerMaille(maille);
var sources = feature.properties.source;
for (var index = 0; index < sources.length; index ++) {
var source = sources[index];
maille.properties.stations[source] = parseInt(feature.properties.stations[source]);
maille.properties.observations[source] = parseInt(feature.properties.observations[source]);
maille.properties.source.push(source);
}
}
 
function regenererInfobulleMailles() {
$('.leaflet-clickable').addClass('tooltip');
coucheSites.eachLayer(function(layer) {
if (layer.typeSite == 'MAILLE') {
genererInfobulle(layer);
function colorerMaille(maille) {
var nombreStations = 0;
var sources = maille.properties.source;
for (var index = 0; index < sources.length; index ++) {
var source = sources[index];
if (typeof(maille.properties.stations[source]) != 'undefined') {
nombreStations += parseInt(maille.properties.stations[source]);
}
});
}
 
function colorerMaille(maille) {
var nombrePoints = 0;
for (sourceMaille in maille.nombrePoints) {
nombrePoints += maille.nombrePoints[sourceMaille];
}
if (nombrePoints > 0) {
if (nombreStations > 0) {
maille.on('click', surClicMaille);
maille.setStyle({fillColor : genererCouleur(nombrePoints), fillOpacity: 0.45, opacity: 0.7});
maille.setStyle({fillColor : genererCouleur(nombreStations), fillOpacity: 0.45, opacity: 0.7});
} else {
maille.setStyle({fillOpacity: 0, opacity: 0});
maille.off('click', surClicMaille);
maille.off('click');
}
}
 
function surClicMaille(event) {
map.fitBounds(event.layer.getBounds());
}
 
function genererCouleur(nombrePoints) {
var couleur = {'bleu': 231, 'vert': 224, 'rouge': 64},
seuils = [1, 10, 50 ,100, 500, 1000, 2500],
622,17 → 611,27
return 'rgb('+couleur.bleu+','+couleur.vert+','+couleur.rouge+')';
}
 
function surClicMaille(event) {
map.fitBounds(event.layer.getBounds());
}
 
function afficherLegende() {
if (legende == null) {
legende = new L.Control({position : 'bottomright'});
legende.onAdd = function(map) {
return construireContenuHtmlLegende();
var contenuHtml = '';
if (typeSite == 'maille') {
contenuHtml = construireContenuHtmlLegendeMailles();
} else {
contenuHtml = construireContenuHtmlLegendePoints();
}
return contenuHtml;
};
map.addControl(legende);
}
}
 
function construireContenuHtmlLegende() {
function construireContenuHtmlLegendeMailles() {
var div = L.DomUtil.create('div', 'info');
div.innerHTML = '<h4>' + titreLegende + '</h4>';
var seuils = [1, 10, 50 ,100, 500, 1000, 2500];
640,8 → 639,8
for (var i = 0; i < seuils.length; i ++) {
div.innerHTML +=
'<div class="legend">'+
'<span style="background:' + genererCouleur(seuils[i] + 1) + '"></span>'+
seuils[i]+ (i + 1 < seuils.length ? '&ndash;' + seuils[i + 1] : '+')+
'<span class="couleur-maille" style="background:' + genererCouleur(seuils[i] + 1) + '">'+
'</span>'+seuils[i]+ (i + 1 < seuils.length ? '&ndash;' + seuils[i + 1] : '+')+
'</div>';
}
return div;
654,29 → 653,41
}
}
 
function supprimerSourceDansMaille(maille, sourceSuppression) {
if (typeof(maille.nombrePoints[sourceSuppression]) != 'undefined') {
maille.nombrePoints[sourceSuppression] = 0;
colorerMaille(maille);
genererInfobulle(maille);
}
function genererInfobulleMailles() {
coucheSites.eachLayer(function(layer) {
if (layer.typeSite == 'maille') {
genererInfobulle(layer);
}
});
}
 
function genererInfobulle(maille) {
var nombrePoints = 0,
nombreSources = 0;
contenuTexte = '';
for (sourceMaille in maille.nombrePoints) {
nombrePoints = maille.nombrePoints[sourceMaille];
if (nombrePoints > 0) {
contenuTexte += (contenuTexte.length==0 ?'' : '\n')+
sourceMaille+' : '+maille.nombrePoints[sourceMaille];
var sources = maille.properties.source;
var textes = new Array();
for (var index = 0; index < sources.length; index ++) {
var source = sources[index];
if (typeof(maille.properties.stations[source]) != 'undefined') {
textes.push(source+" : "+maille.properties.stations[source]+" stations, "
+maille.properties.observations[source]+" observations");
}
nombreSources ++;
}
if (nombreSources > 0) {
$(maille._path).addClass('tooltip');
$(maille._path).attr('title',contenuTexte);
var contenu = textes.join('<br />');
maille.on('mouseover', function() {
afficherTooltip(contenu, map.latLngToContainerPoint(maille.getBounds().getSouthWest()));
});
maille.on('mouseout', function() {
$("#tooltip").css('display', 'none');
});
}
 
function afficherTooltip(texte, point) {
$("#tooltip").html(texte);
if ($("#tooltip").css('display') == 'none') {
var x = point.x - 15;
var y = point.y + (typeSite == 'maille' ? 1 : 10);
$("#tooltip").css('display', 'block');
$("#tooltip").css('left', x + 'px');
$("#tooltip").css('top', y + 'px');
}
}
 
684,136 → 695,73
 
 
// ====================================================================
// Gestion des marqueurs
// Gestion des points
 
function ajouterPoint(feature) {
var iconePoint = new L.Icon({ iconUrl : pointImageUrl, iconSize : [16, 16] }),
iconeCommune = new L.Icon({ iconUrl : communeImageUrl, iconSize : [24, 32] }),
icone = (feature.properties.typeSite == 'STATION') ? iconePoint : iconeCommune,
point = new L.LatLng(feature.geometry.coordinates[0], feature.geometry.coordinates[1]),
marker = new L.Marker(point, {
icon : icone,
title : feature.properties.nom
})
marker.typeSite = feature.properties.typeSite;
point = new L.LatLng(feature.geometry.coordinates[0], feature.geometry.coordinates[1]);
var marker = new L.Cluster(point, {
icon : icone,
titre : feature.properties.nom
});
marker.typeSite = feature.properties.typeSite.toLowerCase();
marker.source = feature.properties.source;
marker.on('click', surClicMarqueur);
points.push(marker);
if (formeDonnees != 'maille') {
coucheSites.addLayer(marker);
} else {
ajouterPointDansMaille(marker);
}
}
 
function ajouterPointDansMaille(point) {
var maille = null;
coucheSites.eachLayer(function(layer) {
if (layer.typeSite == 'MAILLE' && layer.getBounds().contains(point.getLatLng())) {
maille = layer;
return;
}
marker.on('mouseover', function() {
afficherTooltip(marker.options.titre, map.latLngToContainerPoint(marker.getLatLng()));
});
if (typeof(maille.nombrePoints[point.source]) == 'undefined') {
maille.nombrePoints[point.source] = 1;
} else {
maille.nombrePoints[point.source] += 1;
}
colorerMaille(maille);
}
 
function combinerMaillesEtPoints() {
enleverMarqueursCarte();
coucheSites.eachLayer(function(layer) {
if (layer.typeSite == 'MAILLE') {
var nombrePoints = compterNombrePointsDansMaille(layer);
ajouterNombrePointsDansMaille(layer, nombrePoints);
}
marker.on('mouseout', function() {
$("#tooltip").css('display', 'none');
});
coucheSites.ajouterPoint(marker);
}
 
function determinerNombreMarqueurs(source) {
var nombrePoints = 0;
for (var index = 0; index < points.length; index ++) {
if (points[index].source == source) {
nombrePoints += 1;
}
}
return nombrePoints;
function construireContenuHtmlLegendePoints() {
var div = L.DomUtil.create('div', 'info');
div.innerHTML =
'<h4>Stations</h4>'+
'<div class="legend"><table>'+
'<tr>'+
'<td class="image-station"><img src="'+communeImageUrl+'" width="24" height="32" /></td>'+
'<td class="label-station">Commune</td>'+
'</tr>'+
'<tr>'+
'<td class="image-station"><img src="'+pointImageUrl+'" /></td>'+
'<td class="label-station">Lieu précis</td>'+
'</tr>'+
'<tr>'+
'<td class="image-station"><img src="'+clusterImageUrl+'" width="20" height="20" /></td>'+
'<td class="label-station">Groupe de stations proches</td>'+
'</tr>'+
'</table></div>';
return div;
}
 
function enleverMarqueursCarte() {
coucheSites.eachLayer(function(layer) {
if (layer.typeSite != 'MAILLE') {
coucheSites.removeLayer(layer);
}
});
}
 
function compterNombrePointsDansMaille(maille) {
var nombrePoints = {};
for (var index = 0; index < points.length; index ++) {
if (maille.getBounds().contains(points[index].getLatLng())) {
var source = points[index].source;
if (typeof(nombrePoints[source]) == 'undefined') {
nombrePoints[source] = 1;
} else {
nombrePoints[source] += 1;
}
}
function surClicMarqueur(event) {
var nombreMarkers = event.target.recupererMarkers().length;
if (nombreMarkers == 1 || map.getZoom() == map.getMaxZoom()) {
recupererObservations(event.target);
} else {
map.setView(event.target.getLatLng(), Math.min(map.getZoom()+2, map.getMaxZoom()));
}
return nombrePoints;
}
 
function ajouterNombrePointsDansMaille(maille, nombrePoints) {
for (sourceDonnees in nombrePoints) {
if (typeof(maille.nombrePoints[sourceDonnees]) == 'undefined') {
maille.nombrePoints[sourceDonnees] = nombrePoints[sourceDonnees];
} else {
maille.nombrePoints[sourceDonnees] += nombrePoints[sourceDonnees];
}
}
colorerMaille(maille);
}
 
function supprimerPointsListe(sourceDonnees) {
var index = 0;
while (index < points.length) {
if (points[index].source == sourceDonnees) {
points.splice(index, 1);
} else {
index ++;
}
}
}
 
function transformerMaillesEnPoints(sourceDonnees) {
coucheSites.eachLayer(function(layer) {
if (layer.typeSite == 'MAILLE' && typeof(layer.nombrePoints[sourceDonnees]) != 'undefined') {
supprimerSourceDansMaille(layer, sourceDonnees);
}
});
for (var index = 0; index < points.length; index ++) {
coucheSites.addLayer(points[index]);
}
}
 
function surClicMarqueur(event) {
var latitude = event.target.getLatLng().lat;
var longitude = event.target.getLatLng().lng;
pointClique = event.target;
function recupererObservations(cluster) {
pointClique = cluster;
var latlng = cluster.getLatLng();
afficherMessageChargement('observations');
var parametres = {
"source" : pointClique.source,
"source" : recupererSourcesCluster(cluster),
"stations" : construireListeStationsCluster(cluster),
"num_taxon" : numTaxon,
"nn" : nn,
"referentiel" : referentiel,
"auteur" : auteur,
"nn" : nn,
"type_site" : pointClique.typeSite,
"date_debut" : dateDebut,
"date_fin" : dateFin,
"longitude" : longitude,
"latitude" : latitude,
"nb_jours" : nbJours
};
url = urlBase + "observations?" + convertirEnParametresUrl(parametres);
821,6 → 769,27
executerAJAX();
}
 
function recupererSourcesCluster(cluster) {
var markers = cluster.recupererMarkers();
var sourcesCluster = [];
for (var index = 0; index < markers.length; index ++) {
if (sourcesCluster.indexOf(markers[index].source) == -1) {
sourcesCluster.push(markers[index].source);
}
}
return sourcesCluster.join(',');
}
 
function construireListeStationsCluster(cluster) {
var markers = cluster.recupererMarkers();
var listePoints = [];
for (var index = 0; index < markers.length; index ++) {
var latlng = markers[index].getLatLng();
listePoints.push(markers[index].source+":"+markers[index].typeSite+":"+latlng.lng+","+latlng.lat);
}
return listePoints.join('|');
}
 
function traiterDonneesObservations() {
masquerMessageChargement();
var texte = requeteChargementPoints.responseText;
841,13 → 810,9
}
}
 
function viderListeObservations() {
obsStation = new Array();
}
 
 
 
 
// ====================================================================
// Gestion de l'infobulle
 
854,18 → 819,26
var obsJSON = null,
pointClique = null,
obsStation = [],
typeAffichage = "";
pagineur = {'limite':100, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
 
function afficherInfoBulle() {
var latitude = pointClique.getLatLng().lat;
var longitude = pointClique.getLatLng().lng;
infoBulle = new L.Popup({maxWidth : definirLargeurInfoBulle(), maxHeight : 350});
infoBulle = new L.Popup({maxWidth : definirLargeurInfoBulle(), maxHeight : 380});
infoBulle.setLatLng(new L.LatLng(latitude, longitude));
infoBulle.setContent($("#tpl-obs").html());
infoBulle.openOn(map);
infoBulle.openOn(map);
remplirContenuPopup();
$('#info-bulle').css('width', '99%');
$('#observations').css('height', '250px');
$('#observations').css('overflow', 'auto');
$('.leaflet-popup-scrolled').css('overflow', 'visible');
}
 
function viderListeObservations() {
obsStation = new Array();
}
 
function definirLargeurInfoBulle() {
var largeurViewPort = $(window).width();
var lageurInfoBulle = null;
880,14 → 853,14
}
 
function redimensionnerPopup() {
$('.leaflet-popup-content*').css('width', definirLargeurInfoBulle());
$('#info-bulle').css('width', definirLargeurInfoBulle());
$('.leaflet-popup-content*').css('width', definirLargeurInfoBulle());
$('#info-bulle').css('width', '99%');
}
 
function remplirContenuPopup() {
ajouterTableauTriable("#obs-tableau");
ajouterTitre();
afficherOnglets();
afficherTableau();
afficherTexteStationId();
}
 
900,23 → 873,18
 
function ajouterTitre() {
var texteStationTitre = obsJSON.total + ' observation' + (obsJSON.total > 1 ? 's' : '')
+ ' pour ' + (pointClique.options.type=='STATION' ? 'la station : ' : 'la commune : ')
+ ' sur ' + (pointClique.typeSite=='station' ? 'la station : ' : 'la commune : ')
+ pointClique.options.title;
$('#obs-station-titre').text(texteStationTitre);
}
 
function selectionnerOnglet() {
$("#obs-vue-" + typeAffichage).css("display", "block");
$('#obs-tableau-lignes').empty();
$('#obs-liste-lignes').empty();
if (typeAffichage=='liste') {
$("#obs-vue-tableau").css("display", "none");
} else {
$("#obs-vue-liste").css("display", "none");
}
function afficherTableau() {
construireListeObservations();
afficherPagination();
afficherObservationsDansHTML();
}
 
function ajouterObservationsDansHTML() {
function construireListeObservations() {
if (obsStation.length==0) {
// premiere execution de la fonction : faire une copie des objets JSON decrivant les observations
for (var index = 0; index < obsJSON.observations.length; index ++) {
923,43 → 891,37
obsStation.push(obsJSON.observations[index]);
}
}
var obsPage = [];
for (var index = 0; index < obsStation.length; index ++) {
obsPage.push(obsStation[index]);
}
$("#tpl-obs-"+typeAffichage).tmpl(obsPage).appendTo("#obs-"+typeAffichage+"-lignes");
pagineur.total = obsStation.length;
}
 
function afficherOnglets() {
var $tabs = $('#obs').tabs();
$('#obs').bind('tabsselect', function(event, ui) {
if (ui.panel.id == 'obs-vue-tableau') {
surClicAffichageTableau();
} else if (ui.panel.id == 'obs-vue-liste') {
surClicAffichageListe();
}
function afficherPagination() {
$(".navigation").pagination(pagineur.total, {
items_per_page:pagineur.limite,
callback:afficherObservationsDansHTML,
next_text:'Suivant',
prev_text:'Précédent',
prev_show_always:false,
num_edge_entries:1,
num_display_entries:4,
load_first_page:true
});
if (obsJSON.total > 4) {
surClicAffichageTableau();
} else {
$tabs.tabs('select', "#obs-vue-liste");
}
}
 
function surClicAffichageTableau() {
typeAffichage = 'tableau';
selectionnerOnglet();
ajouterObservationsDansHTML();
mettreAJourTableauTriable("#obs-tableau");
function afficherObservationsDansHTML(indexPage) {
$("#obs-tableau-lignes").empty();
if (typeof(indexPage) == 'undefined') {
indexPage = 0;
}
var depart = indexPage * pagineur.limite;
var obsPage = [];
for (var index = depart; index < depart + pagineur.limite; index ++) {
obsPage.push(obsStation[index]);
}
$("#tpl-obs-tableau").tmpl(obsPage).appendTo("#obs-tableau-lignes");
mettreAJourTableauTriable();
}
 
function surClicAffichageListe() {
typeAffichage = 'liste';
selectionnerOnglet();
ajouterObservationsDansHTML();
}
 
function ajouterTableauTriable(element) {
function ajouterTableauTriable() {
$.tablesorter.addParser({
id: 'date_cel',
is: function(s) {
968,28 → 930,29
},
format: function(date) {
// Transformation date jj/mm/aaaa en aaaa/mm/jj
date = date.replace(/^\s*(\d{2})[\/-](\d{2})[\/-](\d{4})\s*$/, "$3/$2/$1");
date = date.replace(/^\s*(\d{2})[\/-](\d{2})[\/-](\d{4})\s*$/, "$3-$2-$1");
// Remplace la date par un nombre de millisecondes pour trier numériquement
return $.tablesorter.formatFloat(new Date(date).getTime());
},
type: 'numeric'
});
$(element).tablesorter({
$("#obs-tableau").tablesorter({
headers: {
1: {
sorter:'date_cel'
sorter:'date_cel'
}
}
});
}
 
function mettreAJourTableauTriable(element) {
$(element).trigger('update');
function mettreAJourTableauTriable() {
$("#obs-tableau").trigger('update');
}
 
function afficherTexteStationId() {
var latitude = pointClique.getLatLng().lat;
var longitude = pointClique.getLatLng().lng;
var texteStationId = pointClique.typeSite+':'+latitude+'|'+longitude+', SOURCE:'+pointClique.source;
var latitude = pointClique.getLatLng().lat.toFixed(5);
var longitude = pointClique.getLatLng().lng.toFixed(5);
var texteStationId = pointClique.typeSite.toUpperCase() + ':'
+ latitude + '|' + longitude + ', SOURCE:' + pointClique.source;
$('#obs-station-id').text(texteStationId);
}
/trunk/widget/modules/carto/squelettes/scripts/L.KML.js
166,10 → 166,10
options.color = "#" + value.substring(2, 8);
} else if (key === 'width') {
options.weight = value;
} /*else if (key === 'Icon') {
} else if (key === 'Icon') {
ioptions = _parse(e);
if (ioptions.href) { options.href = ioptions.href; }
}*/ else if (key === 'href') {
} else if (key === 'href') {
options.href = value;
}
}
272,9 → 272,9
}
}
 
if (name) {
/*if (name) {
layer.bindPopup("<h2>" + name + "</h2>" + descr);
}
}*/
 
return layer;
},
/trunk/widget/modules/carto/squelettes/scripts/leaflet.markercluster.js
New file
0,0 → 1,6
/*
Copyright (c) 2012, Smartrak, David Leaver
Leaflet.markercluster is an open-source JavaScript library for Marker Clustering on leaflet powered maps.
https://github.com/danzel/Leaflet.markercluster
*/
(function(){L.MarkerClusterGroup=L.FeatureGroup.extend({options:{maxClusterRadius:80,iconCreateFunction:null,spiderfyOnMaxZoom:!0,showCoverageOnHover:!0,zoomToBoundsOnClick:!0,singleMarkerMode:!1,disableClusteringAtZoom:null,removeOutsideVisibleBounds:!0,animateAddingMarkers:!1,spiderfyDistanceMultiplier:1,polygonOptions:{}},initialize:function(t){L.Util.setOptions(this,t),this.options.iconCreateFunction||(this.options.iconCreateFunction=this._defaultIconCreateFunction),L.FeatureGroup.prototype.initialize.call(this,[]),this._inZoomAnimation=0,this._needsClustering=[],this._needsRemoving=[],this._currentShownBounds=null},addLayer:function(t){if(t instanceof L.LayerGroup){var e=[];for(var i in t._layers)e.push(t._layers[i]);return this.addLayers(e)}if(!this._map)return this._needsClustering.push(t),this;if(this.hasLayer(t))return this;this._unspiderfy&&this._unspiderfy(),this._addLayer(t,this._maxZoom);var n=t,r=this._map.getZoom();if(t.__parent)for(;n.__parent._zoom>=r;)n=n.__parent;return this._currentShownBounds.contains(n.getLatLng())&&(this.options.animateAddingMarkers?this._animationAddLayer(t,n):this._animationAddLayerNonAnimated(t,n)),this},removeLayer:function(t){return this._map?t.__parent?(this._unspiderfy&&(this._unspiderfy(),this._unspiderfyLayer(t)),this._removeLayer(t,!0),t._icon&&(L.FeatureGroup.prototype.removeLayer.call(this,t),t.setOpacity(1)),this):this:(!this._arraySplice(this._needsClustering,t)&&this.hasLayer(t)&&this._needsRemoving.push(t),this)},addLayers:function(t){var e,i,n;if(!this._map)return this._needsClustering=this._needsClustering.concat(t),this;for(e=0,i=t.length;i>e;e++)if(n=t[e],!this.hasLayer(n)&&(this._addLayer(n,this._maxZoom),n.__parent&&2===n.__parent.getChildCount())){var r=n.__parent.getAllChildMarkers(),s=r[0]===n?r[1]:r[0];L.FeatureGroup.prototype.removeLayer.call(this,s)}for(e in this._layers)n=this._layers[e],n instanceof L.MarkerCluster&&n._iconNeedsUpdate&&n._updateIcon();return this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds),this},removeLayers:function(t){var e,i,n;if(!this._map){for(e=0,i=t.length;i>e;e++)this._arraySplice(this._needsClustering,t[e]);return this}for(e=0,i=t.length;i>e;e++)n=t[e],n.__parent&&(this._removeLayer(n,!0,!0),n._icon&&(L.FeatureGroup.prototype.removeLayer.call(this,n),n.setOpacity(1)));this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds);for(e in this._layers)n=this._layers[e],n instanceof L.MarkerCluster&&n._updateIcon();return this},clearLayers:function(){this._map||(this._needsClustering=[],delete this._gridClusters,delete this._gridUnclustered),this._noanimationUnspiderfy&&this._noanimationUnspiderfy();for(var t in this._layers)L.FeatureGroup.prototype.removeLayer.call(this,this._layers[t]);return this.eachLayer(function(t){delete t.__parent}),this._map&&this._generateInitialClusters(),this},getBounds:function(){var t=new L.LatLngBounds;if(this._topClusterLevel)t.extend(this._topClusterLevel._bounds);else for(var e=this._needsClustering.length-1;e>=0;e--)t.extend(this._needsClustering[e].getLatLng());return t},eachLayer:function(t,e){var i,n=this._needsClustering.slice();for(this._topClusterLevel&&this._topClusterLevel.getAllChildMarkers(n),i=n.length-1;i>=0;i--)t.call(e,n[i])},hasLayer:function(t){if(t._noHas)return!1;var e,i=this._needsClustering;for(e=i.length-1;e>=0;e--)if(i[e]===t)return!0;for(i=this._needsRemoving,e=i.length-1;e>=0;e--)if(i[e]===t)return!1;return!(!t.__parent||t.__parent._group!==this)},zoomToShowLayer:function(t,e){var i=function(){if((t._icon||t.__parent._icon)&&!this._inZoomAnimation)if(this._map.off("moveend",i,this),this.off("animationend",i,this),t._icon)e();else if(t.__parent._icon){var n=function(){this.off("spiderfied",n,this),e()};this.on("spiderfied",n,this),t.__parent.spiderfy()}};t._icon?e():t.__parent._zoom<this._map.getZoom()?(this._map.on("moveend",i,this),t._icon||this._map.panTo(t.getLatLng())):(this._map.on("moveend",i,this),this.on("animationend",i,this),this._map.setView(t.getLatLng(),t.__parent._zoom+1),t.__parent.zoomToBounds())},onAdd:function(t){this._map=t;var e,i,n;for(this._gridClusters||this._generateInitialClusters(),e=0,i=this._needsRemoving.length;i>e;e++)n=this._needsRemoving[e],this._removeLayer(n);for(this._needsRemoving=[],e=0,i=this._needsClustering.length;i>e;e++)n=this._needsClustering[e],n.__parent||this._addLayer(n,this._maxZoom);this._needsClustering=[],this._map.on("zoomend",this._zoomEnd,this),this._map.on("moveend",this._moveEnd,this),this._spiderfierOnAdd&&this._spiderfierOnAdd(),this._bindEvents(),this._zoom=this._map.getZoom(),this._currentShownBounds=this._getExpandedVisibleBounds(),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds)},onRemove:function(t){t.off("zoomend",this._zoomEnd,this),t.off("moveend",this._moveEnd,this),this._unbindEvents(),this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim",""),this._spiderfierOnRemove&&this._spiderfierOnRemove();for(var e in this._layers)L.FeatureGroup.prototype.removeLayer.call(this,this._layers[e]);this._map=null},_arraySplice:function(t,e){for(var i=t.length-1;i>=0;i--)if(t[i]===e)return t.splice(i,1),!0},_removeLayer:function(t,e,i){var n=this._gridClusters,r=this._gridUnclustered,s=this._map;if(e)for(var o=this._maxZoom;o>=0&&r[o].removeObject(t,s.project(t.getLatLng(),o));o--);var a,l=t.__parent,_=l._markers;for(this._arraySplice(_,t);l&&(l._childCount--,!(0>l._zoom));)e&&1>=l._childCount?(a=l._markers[0]===t?l._markers[1]:l._markers[0],n[l._zoom].removeObject(l,s.project(l._cLatLng,l._zoom)),r[l._zoom].addObject(a,s.project(a.getLatLng(),l._zoom)),this._arraySplice(l.__parent._childClusters,l),l.__parent._markers.push(a),a.__parent=l.__parent,l._icon&&(L.FeatureGroup.prototype.removeLayer.call(this,l),i||L.FeatureGroup.prototype.addLayer.call(this,a))):(l._recalculateBounds(),i&&l._icon||l._updateIcon()),l=l.__parent;delete t.__parent},_propagateEvent:function(t){t.target instanceof L.MarkerCluster&&(t.type="cluster"+t.type),L.FeatureGroup.prototype._propagateEvent.call(this,t)},_defaultIconCreateFunction:function(t){var e=t.getChildCount(),i=" marker-cluster-";return i+=10>e?"small":100>e?"medium":"large",new L.DivIcon({html:"<div><span>"+e+"</span></div>",className:"marker-cluster"+i,iconSize:new L.Point(40,40)})},_bindEvents:function(){var t=null,e=this._map,i=this.options.spiderfyOnMaxZoom,n=this.options.showCoverageOnHover,r=this.options.zoomToBoundsOnClick;(i||r)&&this.on("clusterclick",function(t){e.getMaxZoom()===e.getZoom()?i&&t.layer.spiderfy():r&&t.layer.zoomToBounds()},this),n&&(this.on("clustermouseover",function(i){this._inZoomAnimation||(t&&e.removeLayer(t),i.layer.getChildCount()>2&&i.layer!==this._spiderfied&&(t=new L.Polygon(i.layer.getConvexHull(),this.options.polygonOptions),e.addLayer(t)))},this),this.on("clustermouseout",function(){t&&(e.removeLayer(t),t=null)},this),e.on("zoomend",function(){t&&(e.removeLayer(t),t=null)},this),e.on("layerremove",function(i){t&&i.layer===this&&(e.removeLayer(t),t=null)},this))},_unbindEvents:function(){var t=this.options.spiderfyOnMaxZoom,e=this.options.showCoverageOnHover,i=this.options.zoomToBoundsOnClick,n=this._map;(t||i)&&this.off("clusterclick",null,this),e&&(this.off("clustermouseover",null,this),this.off("clustermouseout",null,this),n.off("zoomend",null,this),n.off("layerremove",null,this))},_zoomEnd:function(){this._map&&(this._mergeSplitClusters(),this._zoom=this._map._zoom,this._currentShownBounds=this._getExpandedVisibleBounds())},_moveEnd:function(){if(!this._inZoomAnimation){var t=this._getExpandedVisibleBounds();this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,this._zoom,t),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,t),this._currentShownBounds=t}},_generateInitialClusters:function(){var t=this._map.getMaxZoom(),e=this.options.maxClusterRadius;this.options.disableClusteringAtZoom&&(t=this.options.disableClusteringAtZoom-1),this._maxZoom=t,this._gridClusters={},this._gridUnclustered={};for(var i=t;i>=0;i--)this._gridClusters[i]=new L.DistanceGrid(e),this._gridUnclustered[i]=new L.DistanceGrid(e);this._topClusterLevel=new L.MarkerCluster(this,-1)},_addLayer:function(t,e){var i,n,r=this._gridClusters,s=this._gridUnclustered;for(this.options.singleMarkerMode&&(t.options.icon=this.options.iconCreateFunction({getChildCount:function(){return 1},getAllChildMarkers:function(){return[t]}}));e>=0;e--){i=this._map.project(t.getLatLng(),e);var o=r[e].getNearObject(i);if(o)return o._addChild(t),t.__parent=o,void 0;if(o=s[e].getNearObject(i)){var a=o.__parent;a&&this._removeLayer(o,!1);var l=new L.MarkerCluster(this,e,o,t);r[e].addObject(l,this._map.project(l._cLatLng,e)),o.__parent=l,t.__parent=l;var _=l;for(n=e-1;n>a._zoom;n--)_=new L.MarkerCluster(this,n,_),r[n].addObject(_,this._map.project(o.getLatLng(),n));for(a._addChild(_),n=e;n>=0&&s[n].removeObject(o,this._map.project(o.getLatLng(),n));n--);return}s[e].addObject(t,i)}this._topClusterLevel._addChild(t),t.__parent=this._topClusterLevel},_mergeSplitClusters:function(){this._zoom<this._map._zoom?(this._animationStart(),this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,this._zoom,this._getExpandedVisibleBounds()),this._animationZoomIn(this._zoom,this._map._zoom)):this._zoom>this._map._zoom?(this._animationStart(),this._animationZoomOut(this._zoom,this._map._zoom)):this._moveEnd()},_getExpandedVisibleBounds:function(){if(!this.options.removeOutsideVisibleBounds)return this.getBounds();var t=this._map,e=t.getBounds(),i=e._southWest,n=e._northEast,r=L.Browser.mobile?0:Math.abs(i.lat-n.lat),s=L.Browser.mobile?0:Math.abs(i.lng-n.lng);return new L.LatLngBounds(new L.LatLng(i.lat-r,i.lng-s,!0),new L.LatLng(n.lat+r,n.lng+s,!0))},_animationAddLayerNonAnimated:function(t,e){if(e===t)L.FeatureGroup.prototype.addLayer.call(this,t);else if(2===e._childCount){e._addToMap();var i=e.getAllChildMarkers();L.FeatureGroup.prototype.removeLayer.call(this,i[0]),L.FeatureGroup.prototype.removeLayer.call(this,i[1])}else e._updateIcon()}}),L.MarkerClusterGroup.include(L.DomUtil.TRANSITION?{_animationStart:function(){this._map._mapPane.className+=" leaflet-cluster-anim",this._inZoomAnimation++},_animationEnd:function(){this._map&&(this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim","")),this._inZoomAnimation--,this.fire("animationend")},_animationZoomIn:function(t,e){var i,n=this,r=this._getExpandedVisibleBounds();this._topClusterLevel._recursively(r,t,0,function(s){var o,a=s._latlng,l=s._markers;for(s._isSingleParent()&&t+1===e?(L.FeatureGroup.prototype.removeLayer.call(n,s),s._recursivelyAddChildrenToMap(null,e,r)):(s.setOpacity(0),s._recursivelyAddChildrenToMap(a,e,r)),i=l.length-1;i>=0;i--)o=l[i],r.contains(o._latlng)||L.FeatureGroup.prototype.removeLayer.call(n,o)}),this._forceLayout();var s,o;n._topClusterLevel._recursivelyBecomeVisible(r,e);for(s in n._layers)o=n._layers[s],o instanceof L.MarkerCluster||!o._icon||o.setOpacity(1);n._topClusterLevel._recursively(r,t,e,function(t){t._recursivelyRestoreChildPositions(e)}),setTimeout(function(){n._topClusterLevel._recursively(r,t,0,function(t){L.FeatureGroup.prototype.removeLayer.call(n,t),t.setOpacity(1)}),n._animationEnd()},200)},_animationZoomOut:function(t,e){this._animationZoomOutSingle(this._topClusterLevel,t-1,e),this._topClusterLevel._recursivelyAddChildrenToMap(null,e,this._getExpandedVisibleBounds()),this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,t,this._getExpandedVisibleBounds())},_animationZoomOutSingle:function(t,e,i){var n=this._getExpandedVisibleBounds();t._recursivelyAnimateChildrenInAndAddSelfToMap(n,e+1,i);var r=this;this._forceLayout(),t._recursivelyBecomeVisible(n,i),setTimeout(function(){if(1===t._childCount){var s=t._markers[0];s.setLatLng(s.getLatLng()),s.setOpacity(1)}else t._recursively(n,i,0,function(t){t._recursivelyRemoveChildrenFromMap(n,e+1)});r._animationEnd()},200)},_animationAddLayer:function(t,e){var i=this;L.FeatureGroup.prototype.addLayer.call(this,t),e!==t&&(e._childCount>2?(e._updateIcon(),this._forceLayout(),this._animationStart(),t._setPos(this._map.latLngToLayerPoint(e.getLatLng())),t.setOpacity(0),setTimeout(function(){L.FeatureGroup.prototype.removeLayer.call(i,t),t.setOpacity(1),i._animationEnd()},200)):(this._forceLayout(),i._animationStart(),i._animationZoomOutSingle(e,this._map.getMaxZoom(),this._map.getZoom())))},_forceLayout:function(){L.Util.falseFn(document.body.offsetWidth)}}:{_animationStart:function(){},_animationZoomIn:function(t,e){this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,t),this._topClusterLevel._recursivelyAddChildrenToMap(null,e,this._getExpandedVisibleBounds())},_animationZoomOut:function(t,e){this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,t),this._topClusterLevel._recursivelyAddChildrenToMap(null,e,this._getExpandedVisibleBounds())},_animationAddLayer:function(t,e){this._animationAddLayerNonAnimated(t,e)}}),L.MarkerCluster=L.Marker.extend({initialize:function(t,e,i,n){L.Marker.prototype.initialize.call(this,i?i._cLatLng||i.getLatLng():new L.LatLng(0,0),{icon:this}),this._group=t,this._zoom=e,this._markers=[],this._childClusters=[],this._childCount=0,this._iconNeedsUpdate=!0,this._bounds=new L.LatLngBounds,i&&this._addChild(i),n&&this._addChild(n)},getAllChildMarkers:function(t){t=t||[];for(var e=this._childClusters.length-1;e>=0;e--)this._childClusters[e].getAllChildMarkers(t);for(var i=this._markers.length-1;i>=0;i--)t.push(this._markers[i]);return t},getChildCount:function(){return this._childCount},zoomToBounds:function(){this._group._map.fitBounds(this._bounds)},getBounds:function(){var t=new L.LatLngBounds;return t.extend(this._bounds),t},_updateIcon:function(){this._iconNeedsUpdate=!0,this._icon&&this.setIcon(this)},createIcon:function(){return this._iconNeedsUpdate&&(this._iconObj=this._group.options.iconCreateFunction(this),this._iconNeedsUpdate=!1),this._iconObj.createIcon()},createShadow:function(){return this._iconObj.createShadow()},_addChild:function(t,e){this._iconNeedsUpdate=!0,this._expandBounds(t),t instanceof L.MarkerCluster?(e||(this._childClusters.push(t),t.__parent=this),this._childCount+=t._childCount):(e||this._markers.push(t),this._childCount++),this.__parent&&this.__parent._addChild(t,!0)},_expandBounds:function(t){var e,i=t._wLatLng||t._latlng;t instanceof L.MarkerCluster?(this._bounds.extend(t._bounds),e=t._childCount):(this._bounds.extend(i),e=1),this._cLatLng||(this._cLatLng=t._cLatLng||i);var n=this._childCount+e;this._wLatLng?(this._wLatLng.lat=(i.lat*e+this._wLatLng.lat*this._childCount)/n,this._wLatLng.lng=(i.lng*e+this._wLatLng.lng*this._childCount)/n):this._latlng=this._wLatLng=new L.LatLng(i.lat,i.lng)},_addToMap:function(t){t&&(this._backupLatlng=this._latlng,this.setLatLng(t)),this._noHas=!0,L.FeatureGroup.prototype.addLayer.call(this._group,this),delete this._noHas},_recursivelyAnimateChildrenIn:function(t,e,i){this._recursively(t,0,i-1,function(t){var i,n,r=t._markers;for(i=r.length-1;i>=0;i--)n=r[i],n._icon&&(n._setPos(e),n.setOpacity(0))},function(t){var i,n,r=t._childClusters;for(i=r.length-1;i>=0;i--)n=r[i],n._icon&&(n._setPos(e),n.setOpacity(0))})},_recursivelyAnimateChildrenInAndAddSelfToMap:function(t,e,i){this._recursively(t,i,0,function(n){n._recursivelyAnimateChildrenIn(t,n._group._map.latLngToLayerPoint(n.getLatLng()).round(),e),n._isSingleParent()&&e-1===i?(n.setOpacity(1),n._recursivelyRemoveChildrenFromMap(t,e)):n.setOpacity(0),n._addToMap()})},_recursivelyBecomeVisible:function(t,e){this._recursively(t,0,e,null,function(t){t.setOpacity(1)})},_recursivelyAddChildrenToMap:function(t,e,i){this._recursively(i,-1,e,function(n){if(e!==n._zoom)for(var r=n._markers.length-1;r>=0;r--){var s=n._markers[r];i.contains(s._latlng)&&(t&&(s._backupLatlng=s.getLatLng(),s.setLatLng(t),s.setOpacity(0)),s._noHas=!0,L.FeatureGroup.prototype.addLayer.call(n._group,s),delete s._noHas)}},function(e){e._addToMap(t)})},_recursivelyRestoreChildPositions:function(t){for(var e=this._markers.length-1;e>=0;e--){var i=this._markers[e];i._backupLatlng&&(i.setLatLng(i._backupLatlng),delete i._backupLatlng)}if(t-1===this._zoom)for(var n=this._childClusters.length-1;n>=0;n--)this._childClusters[n]._restorePosition();else for(var r=this._childClusters.length-1;r>=0;r--)this._childClusters[r]._recursivelyRestoreChildPositions(t)},_restorePosition:function(){this._backupLatlng&&(this.setLatLng(this._backupLatlng),delete this._backupLatlng)},_recursivelyRemoveChildrenFromMap:function(t,e,i){var n,r;this._recursively(t,-1,e-1,function(t){for(r=t._markers.length-1;r>=0;r--)n=t._markers[r],i&&i.contains(n._latlng)||(L.FeatureGroup.prototype.removeLayer.call(t._group,n),n.setOpacity(1))},function(t){for(r=t._childClusters.length-1;r>=0;r--)n=t._childClusters[r],i&&i.contains(n._latlng)||((!L.FeatureGroup.prototype.hasLayer||L.FeatureGroup.prototype.hasLayer.call(t._group,n))&&L.FeatureGroup.prototype.removeLayer.call(t._group,n),n.setOpacity(1))})},_recursively:function(t,e,i,n,r){var s,o,a=this._childClusters,l=this._zoom;if(e>l)for(s=a.length-1;s>=0;s--)o=a[s],t.intersects(o._bounds)&&o._recursively(t,e,i,n,r);else if(n&&n(this),r&&this._zoom===i&&r(this),i>l)for(s=a.length-1;s>=0;s--)o=a[s],t.intersects(o._bounds)&&o._recursively(t,e,i,n,r)},_recalculateBounds:function(){var t,e=this._markers,i=this._childClusters;for(this._bounds=new L.LatLngBounds,delete this._wLatLng,t=e.length-1;t>=0;t--)this._expandBounds(e[t]);for(t=i.length-1;t>=0;t--)this._expandBounds(i[t])},_isSingleParent:function(){return this._childClusters.length>0&&this._childClusters[0]._childCount===this._childCount}}),L.DistanceGrid=function(t){this._cellSize=t,this._sqCellSize=t*t,this._grid={},this._objectPoint={}},L.DistanceGrid.prototype={addObject:function(t,e){var i=this._getCoord(e.x),n=this._getCoord(e.y),r=this._grid,s=r[n]=r[n]||{},o=s[i]=s[i]||[],a=L.Util.stamp(t);this._objectPoint[a]=e,o.push(t)},updateObject:function(t,e){this.removeObject(t),this.addObject(t,e)},removeObject:function(t,e){var i,n,r=this._getCoord(e.x),s=this._getCoord(e.y),o=this._grid,a=o[s]=o[s]||{},l=a[r]=a[r]||[];for(delete this._objectPoint[L.Util.stamp(t)],i=0,n=l.length;n>i;i++)if(l[i]===t)return l.splice(i,1),1===n&&delete a[r],!0},eachObject:function(t,e){var i,n,r,s,o,a,l,_=this._grid;for(i in _){o=_[i];for(n in o)for(a=o[n],r=0,s=a.length;s>r;r++)l=t.call(e,a[r]),l&&(r--,s--)}},getNearObject:function(t){var e,i,n,r,s,o,a,l,_=this._getCoord(t.x),h=this._getCoord(t.y),u=this._objectPoint,d=this._sqCellSize,p=null;for(e=h-1;h+1>=e;e++)if(r=this._grid[e])for(i=_-1;_+1>=i;i++)if(s=r[i])for(n=0,o=s.length;o>n;n++)a=s[n],l=this._sqDist(u[L.Util.stamp(a)],t),d>l&&(d=l,p=a);return p},_getCoord:function(t){return Math.floor(t/this._cellSize)},_sqDist:function(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n}},function(){L.QuickHull={getDistant:function(t,e){var i=e[1].lat-e[0].lat,n=e[0].lng-e[1].lng;return n*(t.lat-e[0].lat)+i*(t.lng-e[0].lng)},findMostDistantPointFromBaseLine:function(t,e){var i,n,r,s=0,o=null,a=[];for(i=e.length-1;i>=0;i--)n=e[i],r=this.getDistant(n,t),r>0&&(a.push(n),r>s&&(s=r,o=n));return{maxPoint:o,newPoints:a}},buildConvexHull:function(t,e){var i=[],n=this.findMostDistantPointFromBaseLine(t,e);return n.maxPoint?(i=i.concat(this.buildConvexHull([t[0],n.maxPoint],n.newPoints)),i=i.concat(this.buildConvexHull([n.maxPoint,t[1]],n.newPoints))):[t]},getConvexHull:function(t){var e,i=!1,n=!1,r=null,s=null;for(e=t.length-1;e>=0;e--){var o=t[e];(i===!1||o.lat>i)&&(r=o,i=o.lat),(n===!1||n>o.lat)&&(s=o,n=o.lat)}var a=[].concat(this.buildConvexHull([s,r],t),this.buildConvexHull([r,s],t));return a}}}(),L.MarkerCluster.include({getConvexHull:function(){var t,e,i,n=this.getAllChildMarkers(),r=[],s=[];for(i=n.length-1;i>=0;i--)e=n[i].getLatLng(),r.push(e);for(t=L.QuickHull.getConvexHull(r),i=t.length-1;i>=0;i--)s.push(t[i][0]);return s}}),L.MarkerCluster.include({_2PI:2*Math.PI,_circleFootSeparation:25,_circleStartAngle:Math.PI/6,_spiralFootSeparation:28,_spiralLengthStart:11,_spiralLengthFactor:5,_circleSpiralSwitchover:9,spiderfy:function(){if(this._group._spiderfied!==this&&!this._group._inZoomAnimation){var t,e=this.getAllChildMarkers(),i=this._group,n=i._map,r=n.latLngToLayerPoint(this._latlng);this._group._unspiderfy(),this._group._spiderfied=this,e.length>=this._circleSpiralSwitchover?t=this._generatePointsSpiral(e.length,r):(r.y+=10,t=this._generatePointsCircle(e.length,r)),this._animationSpiderfy(e,t)}},unspiderfy:function(t){this._group._inZoomAnimation||(this._animationUnspiderfy(t),this._group._spiderfied=null)},_generatePointsCircle:function(t,e){var i,n,r=this._group.options.spiderfyDistanceMultiplier*this._circleFootSeparation*(2+t),s=r/this._2PI,o=this._2PI/t,a=[];for(a.length=t,i=t-1;i>=0;i--)n=this._circleStartAngle+i*o,a[i]=new L.Point(e.x+s*Math.cos(n),e.y+s*Math.sin(n))._round();return a},_generatePointsSpiral:function(t,e){var i,n=this._group.options.spiderfyDistanceMultiplier*this._spiralLengthStart,r=this._group.options.spiderfyDistanceMultiplier*this._spiralFootSeparation,s=this._group.options.spiderfyDistanceMultiplier*this._spiralLengthFactor,o=0,a=[];for(a.length=t,i=t-1;i>=0;i--)o+=r/n+5e-4*i,a[i]=new L.Point(e.x+n*Math.cos(o),e.y+n*Math.sin(o))._round(),n+=this._2PI*s/o;return a},_noanimationUnspiderfy:function(){var t,e,i=this._group,n=i._map,r=this.getAllChildMarkers();for(this.setOpacity(1),e=r.length-1;e>=0;e--)t=r[e],L.FeatureGroup.prototype.removeLayer.call(i,t),t._preSpiderfyLatlng&&(t.setLatLng(t._preSpiderfyLatlng),delete t._preSpiderfyLatlng),t.setZIndexOffset(0),t._spiderLeg&&(n.removeLayer(t._spiderLeg),delete t._spiderLeg)}}),L.MarkerCluster.include(L.DomUtil.TRANSITION?{SVG_ANIMATION:function(){return(""+document.createElementNS("http://www.w3.org/2000/svg","animate")).indexOf("SVGAnimate")>-1}(),_animationSpiderfy:function(t,e){var i,n,r,s,o=this,a=this._group,l=a._map,_=l.latLngToLayerPoint(this._latlng);for(i=t.length-1;i>=0;i--)n=t[i],n.setZIndexOffset(1e6),n.setOpacity(0),n._noHas=!0,L.FeatureGroup.prototype.addLayer.call(a,n),delete n._noHas,n._setPos(_);a._forceLayout(),a._animationStart();var h=L.Path.SVG?0:.3,u=L.Path.SVG_NS;for(i=t.length-1;i>=0;i--)if(s=l.layerPointToLatLng(e[i]),n=t[i],n._preSpiderfyLatlng=n._latlng,n.setLatLng(s),n.setOpacity(1),r=new L.Polyline([o._latlng,s],{weight:1.5,color:"#222",opacity:h}),l.addLayer(r),n._spiderLeg=r,L.Path.SVG&&this.SVG_ANIMATION){var d=r._path.getTotalLength();r._path.setAttribute("stroke-dasharray",d+","+d);var p=document.createElementNS(u,"animate");p.setAttribute("attributeName","stroke-dashoffset"),p.setAttribute("begin","indefinite"),p.setAttribute("from",d),p.setAttribute("to",0),p.setAttribute("dur",.25),r._path.appendChild(p),p.beginElement(),p=document.createElementNS(u,"animate"),p.setAttribute("attributeName","stroke-opacity"),p.setAttribute("attributeName","stroke-opacity"),p.setAttribute("begin","indefinite"),p.setAttribute("from",0),p.setAttribute("to",.5),p.setAttribute("dur",.25),r._path.appendChild(p),p.beginElement()}if(o.setOpacity(.3),L.Path.SVG)for(this._group._forceLayout(),i=t.length-1;i>=0;i--)n=t[i]._spiderLeg,n.options.opacity=.5,n._path.setAttribute("stroke-opacity",.5);setTimeout(function(){a._animationEnd(),a.fire("spiderfied")},200)},_animationUnspiderfy:function(t){var e,i,n,r=this._group,s=r._map,o=t?s._latLngToNewLayerPoint(this._latlng,t.zoom,t.center):s.latLngToLayerPoint(this._latlng),a=this.getAllChildMarkers(),l=L.Path.SVG&&this.SVG_ANIMATION;for(r._animationStart(),this.setOpacity(1),i=a.length-1;i>=0;i--)e=a[i],e._preSpiderfyLatlng&&(e.setLatLng(e._preSpiderfyLatlng),delete e._preSpiderfyLatlng,e._setPos(o),e.setOpacity(0),l&&(n=e._spiderLeg._path.childNodes[0],n.setAttribute("to",n.getAttribute("from")),n.setAttribute("from",0),n.beginElement(),n=e._spiderLeg._path.childNodes[1],n.setAttribute("from",.5),n.setAttribute("to",0),n.setAttribute("stroke-opacity",0),n.beginElement(),e._spiderLeg._path.setAttribute("stroke-opacity",0)));setTimeout(function(){var t=0;for(i=a.length-1;i>=0;i--)e=a[i],e._spiderLeg&&t++;for(i=a.length-1;i>=0;i--)e=a[i],e._spiderLeg&&(e.setOpacity(1),e.setZIndexOffset(0),t>1&&L.FeatureGroup.prototype.removeLayer.call(r,e),s.removeLayer(e._spiderLeg),delete e._spiderLeg);r._animationEnd()},200)}}:{_animationSpiderfy:function(t,e){var i,n,r,s,o=this._group,a=o._map;for(i=t.length-1;i>=0;i--)s=a.layerPointToLatLng(e[i]),n=t[i],n._preSpiderfyLatlng=n._latlng,n.setLatLng(s),n.setZIndexOffset(1e6),L.FeatureGroup.prototype.addLayer.call(o,n),r=new L.Polyline([this._latlng,s],{weight:1.5,color:"#222"}),a.addLayer(r),n._spiderLeg=r;this.setOpacity(.3),o.fire("spiderfied")},_animationUnspiderfy:function(){this._noanimationUnspiderfy()}}),L.MarkerClusterGroup.include({_spiderfied:null,_spiderfierOnAdd:function(){this._map.on("click",this._unspiderfyWrapper,this),this._map.options.zoomAnimation?this._map.on("zoomstart",this._unspiderfyZoomStart,this):this._map.on("zoomend",this._unspiderfyWrapper,this),L.Path.SVG&&!L.Browser.touch&&this._map._initPathRoot()},_spiderfierOnRemove:function(){this._map.off("click",this._unspiderfyWrapper,this),this._map.off("zoomstart",this._unspiderfyZoomStart,this),this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._unspiderfy()},_unspiderfyZoomStart:function(){this._map&&this._map.on("zoomanim",this._unspiderfyZoomAnim,this)},_unspiderfyZoomAnim:function(t){L.DomUtil.hasClass(this._map._mapPane,"leaflet-touching")||(this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._unspiderfy(t))},_unspiderfyWrapper:function(){this._unspiderfy()},_unspiderfy:function(t){this._spiderfied&&this._spiderfied.unspiderfy(t)},_noanimationUnspiderfy:function(){this._spiderfied&&this._spiderfied._noanimationUnspiderfy()},_unspiderfyLayer:function(t){t._spiderLeg&&(L.FeatureGroup.prototype.removeLayer.call(this,t),t.setOpacity(1),t.setZIndexOffset(0),this._map.removeLayer(t._spiderLeg),delete t._spiderLeg)}})})(this);
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/trunk/widget/modules/carto/squelettes/scripts/cluster.js
New file
0,0 → 1,104
 
 
L.Cluster = L.Marker.extend({
initialize: function(marker, options) {
L.Marker.prototype.initialize.call(this, marker, options);
this._markers = [this];
},
ajouterMarker: function(marker) {
this._markers.push(marker);
},
recupererMarkers: function() {
return this._markers;
},
obtenirNombreMarkers: function() {
return this._markers.length;
},
supprimerSource: function(sourceSupression) {
var index = 0;
while (index < this._markers.length) {
if (this._markers[index].source == sourceSupression) {
this._markers.splice(index, 1);
} else {
index ++;
}
}
if (this._markers.length == 0 && this._map != null) {
this._map.removeLayer(this);
delete this;
}
}
});
 
 
 
L.ClusterGroup = L.FeatureGroup.extend({
initialize: function(layers) {
L.FeatureGroup.prototype.initialize.call(this, layers);
this._distance = 10;
this._resolution = 0;
this._nombreClusters = 0;
},
 
ajouterPoint: function(layer) {
if (this._resolution == 0) {
this._resolution = (2 * Math.PI * 6378137) / (256 * Math.pow(2, this._map.getZoom()));
}
var seuilCluster = this._distance * this._resolution;
if (typeof(layer._latlng) != 'undefined') {
var indexClusterPlusProche = this._chercherVoisinPlusProche(layer);
var ajoute = false;
if (indexClusterPlusProche != null) {
var distance = this._layers[indexClusterPlusProche].getLatLng().distanceTo(layer.getLatLng());
if (distance < seuilCluster) {
this._layers[indexClusterPlusProche].ajouterMarker(layer);
ajoute = true;
}
}
if (!ajoute) {
this._layers[this._nombreClusters] = layer;
this._nombreClusters ++;
}
}
},
_chercherVoisinPlusProche: function(layer) {
var distance = -1;
var plusProche = null;
for (var numeroLayer in this._layers) {
if (typeof(this._layers[numeroLayer]) != 'undefined') {
var centre = this._layers[numeroLayer].getLatLng();
if (distance == -1 || centre.distanceTo(layer.getLatLng()) < distance) {
plusProche = numeroLayer;
distance = centre.distanceTo(layer.getLatLng());
}
}
}
return plusProche;
},
afficherClusters: function() {
for (var numeroLayer in this._layers) {
if (typeof(this._layers[numeroLayer]) != 'undefined') {
var layer = this._layers[numeroLayer];
if (layer.obtenirNombreMarkers() > 1) {
layer.setIcon(new L.Icon({ iconUrl : clusterImageUrl, iconSize : [20, 20] }))
}
layer.addTo(map);
}
}
},
supprimerPoint: function(layer) {
this.removeLayer(layer);
delete layer;
}
});
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/trunk/widget/modules/carto/squelettes/scripts
Property changes:
Added: svn:ignore
+carto_old.js
/trunk/widget/modules/carto/squelettes/css/MarkerCluster.Default.ie.css
New file
0,0 → 1,22
/* IE 6-8 fallback colors */
.marker-cluster-small {
background-color: rgb(181, 226, 140);
}
.marker-cluster-small div {
background-color: rgb(110, 204, 57);
}
 
.marker-cluster-medium {
background-color: rgb(241, 211, 87);
}
.marker-cluster-medium div {
background-color: rgb(240, 194, 12);
}
 
.marker-cluster-large {
background-color: rgb(253, 156, 115);
}
.marker-cluster-large div {
background-color: rgb(241, 128, 23);
}
 
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/trunk/widget/modules/carto/squelettes/css/MarkerCluster.Default.css
New file
0,0 → 1,38
.marker-cluster-small {
background-color: rgba(181, 226, 140, 0.6);
}
.marker-cluster-small div {
background-color: rgba(110, 204, 57, 0.6);
}
 
.marker-cluster-medium {
background-color: rgba(241, 211, 87, 0.6);
}
.marker-cluster-medium div {
background-color: rgba(240, 194, 12, 0.6);
}
 
.marker-cluster-large {
background-color: rgba(253, 156, 115, 0.6);
}
.marker-cluster-large div {
background-color: rgba(241, 128, 23, 0.6);
}
 
.marker-cluster {
background-clip: padding-box;
border-radius: 20px;
}
.marker-cluster div {
width: 30px;
height: 30px;
margin-left: 5px;
margin-top: 5px;
 
text-align: center;
border-radius: 15px;
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
}
.marker-cluster span {
line-height: 30px;
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/trunk/widget/modules/carto/squelettes/css/carto.css
291,6 → 291,7
width:500px;
}
#observations {
clear: both;
overflow:none;
margin:-1px 0 0 0;
border: 1px solid #AAA;
412,6 → 413,7
.navigation {
padding:5px;
float:right;
display: block;
}
.pagination {
font-size: 80%;
483,7 → 485,7
padding:6px 8px;
font-size:1em;
background:white;
width:100px;
width:110px;
box-shadow:0 0 15px black;
border-radius:5px;
line-height:18px;
497,7 → 499,7
padding :3px;
color:#999;
}
.legend span {
.legend span.couleur-maille {
width:18px;
height:18px;
float:left;
504,9 → 506,34
margin-right:8px;
opacity: 0.7;
}
.nombre-sites {
font-size:0.75em;
font-family:sans-serif;
text-align:center;
color:black;
}
 
.legend table {
border-collapse: separate;
border: none;
}
 
.legend td {
border: none;
}
 
.legend td.image-station {
text-align: center;
}
 
.legend td.label-station {
text-align: left;
font-size: 0.9em;
}
 
#tooltip {
position: absolute;
z-index: 3000;
border: none;
border-radius : 5px;
background-color: lightblue;
padding: 5px;
font-family : sans-serif;
font-size:1.1em;
}
 
#tooltip h3, #tooltip div { margin: 0; }
/trunk/widget/modules/carto/squelettes
Property changes:
Modified: svn:ignore
kml
+
+old_carto.tpl.html