/trunk/widget/modules/carto/config.defaut.ini |
---|
2,5 → 2,13 |
communeImageUrl = "http://www.tela-botanica.org/commun/icones/carto/commune.png" |
pointImageUrl = "http://www.tela-botanica.org/commun/icones/carto/point2.png" |
sourcesDispo = "cel,sophy" |
nomSourcesDispo = "Observations CEL,Données Sophy" |
sourcesDispo = "floradata,sophy" |
sourceParDefaut = "floradata" |
liensVersSources = "http://www.tela-botanica.org/appli:cel,http://sophy.u-3mrs.fr/" |
nomSourcesDispo = "Observations Floradata,Données Sophy" |
titreLegende = "Stations dans maille" |
; Chemin vers le dossier contenant les fichiers kmz des limites communales |
communesKmzChemin = "/home/telabotap/www/carto/kml/communes/,/home/telabotap/www/carto/kml/communes_incompletes/" |
; Template de l'url où charger les fichiers kml des limites communales. |
limitesCommunaleUrlTpl = "http://www.tela-botanica.org/carto/kml/%s/%s" |
/trunk/widget/modules/carto/Carto.php |
---|
5,13 → 5,13 |
const SERVICE_CARTO_NOM = 'carto'; |
const SERVICE_CARTO_ACTION_DEFAUT = 'carto'; |
private $carte; |
private $source; |
private $carte = null; |
private $source = null; |
private $numeroTaxon; |
private $utilisateur; |
private $referentiel; |
private $departement; |
private $numeroTaxon = '*'; |
private $auteur = '*'; |
private $referentiel = '*'; |
private $departement = '*'; |
/** |
46,7 → 46,7 |
$this->numeroTaxon = (isset($num_taxon) ? $num_taxon : '*'); |
$this->departement = (isset($dept) ? $dept : '*'); |
$this->referentiel = (isset($referentiel) ? $referentiel : '*'); |
$this->utilisateur = (isset($utilisateur) ? $utilisateur : '*'); |
$this->auteur = (isset($auteur) ? $auteur : '*'); |
} |
/** |
61,7 → 61,7 |
$widget['donnees']['url_base'] = $url_base; |
$widget['donnees']['source'] = $this->source; |
$widget['donnees']['num_taxon'] = $this->numeroTaxon; |
$widget['donnees']['utilisateur'] = $this->utilisateur; |
$widget['donnees']['auteur'] = $this->auteur; |
$widget['donnees']['departement'] = $this->departement; |
$widget['donnees']['referentiel'] = $this->referentiel; |
71,7 → 71,7 |
$widget['donnees']['sourcesDispo'] = $this->config['carto']['sourcesDispo']; |
$widget['donnees']['nomSourcesDispo'] = $this->config['carto']['nomSourcesDispo']; |
$widget['donnees']['titreLegende'] = $this->config['carto']['titreLegende']; |
$widget['donnees']['url_limites_communales'] = $this->obtenirUrlsLimitesCommunales(); |
$widget['donnees']['urlLimitesCommunales'] = $this->obtenirUrlsLimitesCommunales(); |
$widget['squelette'] = 'carto'; |
return $widget; |
130,7 → 130,7 |
$nom_dossier = basename($dossier_chemin); |
if (!isset($departements_trouves[$departement]) || $departements_trouves[$departement] == $nom_dossier) { |
$dept_protege = preg_quote($departement); |
if (!is_dir($dossier_chemin.'/'.$element) && preg_match("/^$dept_protege(?:_[0-9]+|)\.km[lz]$/", $element)) { |
if (!is_dir($dossier_chemin.'/'.$element) && preg_match("/^$dept_protege(?:_[0-9]+|)\.kml$/", $element)) { |
$fichiers[$element] = $nom_dossier; |
$departements_trouves[$departement] = $nom_dossier; |
} |
/trunk/widget/modules/carto/squelettes/images/tri_decroissant.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
/trunk/widget/modules/carto/squelettes/images/tri_decroissant.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+image/png |
\ No newline at end of property |
/trunk/widget/modules/carto/squelettes/images/tri.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
/trunk/widget/modules/carto/squelettes/images/tri.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+image/png |
\ No newline at end of property |
/trunk/widget/modules/carto/squelettes/images/tri_croissant.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
/trunk/widget/modules/carto/squelettes/images/tri_croissant.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+image/png |
\ No newline at end of property |
/trunk/widget/modules/carto/squelettes/scripts/carto.js |
---|
1,9 → 1,9 |
// Javascript Document |
//============================================================== |
// ============================================================== |
// FONCTIONS ADDITIONNELLES POUR GERER LES URLS |
convertirEnParametresUrl = function(objet) { |
function convertirEnParametresUrl(objet) { |
var parametresUrl = ''; |
for (attribut in objet) { |
if (typeof(objet[attribut]) == 'function' || typeof(objet[attribut]) == 'undefined' || |
14,39 → 14,53 |
return parametresUrl; |
}; |
parametreDansUrl = function(nomParametre) { |
function estParametreDansUrl(nomParametre) { |
var estDansUrl = false; |
var listeParametres = location.search.substring(1).split("&"); |
for (var index = 0; index < listeParametres.length; index ++) { |
var split = listeParametres[index].split("="); |
if (split[0] == nomParametre) { |
return true; |
estDansUrl = true; |
} |
} |
return false; |
return estDansUrl; |
}; |
//============================================================= |
// ============================================================= |
var map = null, |
optionsCoucheOSM = { |
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors,' |
+ ' <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>', |
maxZoom: 18 |
}, |
optionsCoucheGoogle = { |
attribution: 'Map data ©' + 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", |
optionsCoucheOSM), |
couchePlanGoogle = new L.TileLayer("http://mt1.google.com/vt/lyrs=m&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, |
minZoom : 3, |
maxBounds : [[-85.051129, -180], [85.051129, 180]] |
maxBounds : [[-85.051129, -180], [85.051129, 180]], |
layers : [couchePlanGoogle] |
}, |
coucheOSM, couchePlanGoogle, coucheSatelliteGoogle, |
bordure = null, |
legende = null; |
legende = null, |
infoBulle = null; |
var iconePoint = new L.Icon({ iconUrl : pointImageUrl, iconSize : [16, 16] }), |
iconeCommune = new L.Icon({ iconUrl : communeImageUrl, iconSize : [24, 32] }); |
var coucheSites = new L.FeatureGroup(), |
overlays = []; |
var requeteChargementPoints = null, |
doitRafraichirCarte = true, |
timer = null, |
url = ''; |
62,7 → 76,7 |
initialiserListeners(); |
initialiserPanneauControle(); |
chargerLimitesCommunales(); |
if (!parametreDansUrl('source')) { |
if (!estParametreDansUrl('source')) { |
initialiserSources(); |
} |
programmerRafraichissementCarte(); |
70,6 → 84,9 |
$(window).resize(function() { |
dimensionnerCarte(); |
if (infoBulle != null) { |
redimensionnerPopup(); |
} |
}); |
80,30 → 97,11 |
function initialiserCarte() { |
dimensionnerCarte(); |
// afficher la carte et ajouter un fond cartographique OpenStreetMap |
map = L.map('map', optionsCarte); |
coucheSites.addTo(map); |
var optionsCoucheOSM = { |
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors,' |
+ ' <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>', |
maxZoom: 18 |
}; |
var optionsCoucheGoogle = { |
attribution: 'Map data ©' + 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", |
optionsCoucheOSM); |
coucheOSM.addTo(map); |
couchePlanGoogle = new L.TileLayer("http://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}", |
optionsCoucheGoogle); |
couchePlanGoogle.addTo(map); |
coucheSatelliteGoogle = new L.TileLayer("http://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}", |
optionsCoucheGoogle); |
coucheSatelliteGoogle.addTo(map); |
// ajout echelle |
var echelle = new L.Control.Scale({ |
maxWidth : 100, |
metric : true, |
112,26 → 110,12 |
}); |
map.addControl(echelle); |
} |
function chargerLimitesCommunales() { |
/*if (urlsLimitesCommunales != null) { |
for (urlId in urlsLimitesCommunales) { |
var url = urlsLimitesCommunales[urlId]; |
var track = new L.KML(url, {async: true}); |
/*ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true}); |
alert(url); |
ctaLayer.setMap(map); |
} |
}*/ |
} |
function initialiserListeners() { |
// evenements sur deplacement ou zoom sur la carte |
map.on('moveend', programmerRafraichissementCarte); |
map.on('zoomend', programmerRafraichissementCarte); |
map.on('moveend', surChangementVueSurCarte); |
map.on('zoomend', surChangementVueSurCarte); |
map.on('popupclose', function(e) { |
masquerInfoBulle(); |
programmerRafraichissementCarte(); |
}); |
} |
143,12 → 127,15 |
}; |
var overlayMaps = {}; |
if (!parametreDansUrl('source')) { |
if (!estParametreDansUrl('source')) { |
for (var index = 0; index < nomSources.length; index ++) { |
overlayMaps[nomSources[index]] = new L.LayerGroup(); |
} |
} |
L.control.layers(baseMaps, overlayMaps).addTo(map); |
coucheOSM.bringToBack(); |
couchePlanGoogle.bringToFront(); |
coucheSatelliteGoogle.bringToBack(); |
// garder par defaut la couche plan google comme selectionnee dans le panel |
var selecteursFonds = $('.leaflet-control-layers-base .leaflet-control-layers-selector'); |
155,11 → 142,21 |
selecteursFonds[0].checked = false; |
selecteursFonds[1].checked = true; |
selecteursFonds[2].checked = false; |
coucheOSM.bringToBack(); |
couchePlanGoogle.bringToFront(); |
coucheSatelliteGoogle.bringToBack(); |
} |
function chargerLimitesCommunales() { |
if (urlsLimitesCommunales != null) { |
for (var index = 0; index < urlsLimitesCommunales.length; index ++) { |
var url = urlsLimitesCommunales[index]; |
var coucheDepartement = new L.KML(url, {async: true}); |
coucheDepartement.on("loaded", function(e) { |
map.fitBounds(e.target.getBounds()); |
}); |
map.addLayer(coucheDepartement); |
} |
} |
} |
function initialiserSources() { |
overlays = $('.leaflet-control-layers-overlays .leaflet-control-layers-selector'); |
$.each(overlays, function (index, input) { |
176,6 → 173,13 |
}); |
} |
function surChangementVueSurCarte() { |
if (doitRafraichirCarte == false) { |
doitRafraichirCarte = true; |
} else { |
programmerRafraichissementCarte(); |
} |
} |
function programmerRafraichissementCarte() { |
if(timer != null) { |
199,7 → 203,7 |
function changerSource(projetClique) { |
// dechecker les autres controles d'overlays dans le panel |
// deselctionner les autres boutons des controles d'overlays dans le panel |
for (var index = 0; index < overlays.length; index ++) { |
if (overlays[index].value != projetClique) { |
overlays[index].checked = false; |
233,7 → 237,7 |
requeteChargementPoints.abort(); |
} |
requeteChargementPoints = $.getJSON(url).complete(function() { |
fonctionCallback(requeteChargementPoints.responseText); |
fonctionCallback(); |
}); |
} |
241,38 → 245,37 |
return (requeteChargementPoints != null && requeteChargementPoints.readyState != 4); |
} |
function retourRequeteOK() { |
return ((requeteChargementPoints.status == 200 || requeteChargementPoints.status == 304) |
|| requeteChargementPoints.status == 0); |
} |
function chargerLocalisations() { |
// generer l'URL du script a interroger sur le serveur |
bordure = map.getBounds(); |
var coordonneesBordure = calculerCoordonneesBordure(); |
var parametres = {"num_taxon" : num_taxon, "referentiel" : referentiel, "dept" : dept, |
"utilisateur" : utilisateur, "bbox" : coordonneesBordure, "zoom" : map.getZoom()}; |
url = urlBase + source + "/stations?" + convertirEnParametresUrl(parametres); |
var parametres = { |
"source" : source, |
"num_taxon" : num_taxon, |
"referentiel" : referentiel, |
"dept" : dept, |
"auteur" : auteur, |
"bbox" : coordonneesBordure, |
"zoom" : map.getZoom() |
}; |
url = urlBase + "stations?" + convertirEnParametresUrl(parametres); |
fonctionCallback = function(JSONtext) { |
masquerMessageChargement(); |
if (requeteChargementPoints.status != 200 && requeteChargementPoints.status != 304 |
&& typeof(JSONtext) != 'undefined') { |
alert(JSONtext); |
return; |
} |
var data = eval("(function(){return " + JSONtext + ";})()"); |
if (typeof(data) != 'undefined' && typeof(data.features) != 'undefined') { |
ajouterObjets(data); |
} |
} |
fonctionCallback = traiterDonneesStations; |
executerAJAX(); |
} |
} |
function calculerCoordonneesBordure() { |
var bordure = map.getBounds(); |
var ouest = bordure.getSouthWest().lng, |
sud = Math.max(bordure.getSouthWest().lat, -85.051129), |
est = bordure.getNorthEast().lng, |
nord = Math.min(bordure.getNorthEast().lat, 85.051129); |
// 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) { |
285,40 → 288,43 |
} else if (est > 180) { |
est -= 360; |
} |
return [ouest, sud, est, nord].join(','); |
} |
function traiterDonneesStations() { |
masquerMessageChargement(); |
var texte = requeteChargementPoints.responseText; |
if (!retourRequeteOK()) { |
alert(texte); |
} else { |
var donneesJSON = eval("(function(){return " + texte + ";})()"); |
if (typeof(donneesJSON) != 'undefined' && typeof(donneesJSON.features) != 'undefined') { |
ajouterObjets(donneesJSON); |
} |
} |
} |
function ajouterObjets(data) { |
coucheSites.clearLayers(); |
var contientMailles = false; |
// ajout des nouveaux points a la couche |
for (var i = 0; i < data.features.length; i ++) { |
var typeSite = data.features[i].properties.typeSite; |
var objet = null; |
switch (typeSite) { |
case 'MAILLE' : { |
contientMailles = true; |
ajouterMaille(data.features[i]); |
var contientMailles = (data.features[0].properties.typeSite == 'MAILLE'); |
for (var index = 0; index < data.features.length; index ++) { |
switch (data.features[index].properties.typeSite) { |
case 'MAILLE' : ajouterMaille(data.features[index]); |
break; |
} |
case 'COMMUNE' : |
case 'STATION' : { |
ajouterPoint(data.features[i]); |
case 'STATION' : ajouterPoint(data.features[index]); |
break; |
} |
} |
} |
// afficher/masquer la legende |
if (contientMailles) { |
if (contientMailles && legende == null) { |
afficherLegende(); |
} else { |
} else if (legende != null) { |
masquerLegende(); |
} |
} |
function ajouterMaille(feature) { |
var coordonnees = []; |
for (var i = 0; i < feature.geometry.coordinates.length; i++) { |
342,20 → 348,15 |
} |
function afficherNombreStationsDansMaille(maille) { |
var recul = 0; |
if (maille.nombrePoints >= 10000) { |
recul = 14; |
} else if (maille.nombrePoints >= 1000) { |
recul = 9; |
} else if (maille.nombrePoints >= 100) { |
recul = 5; |
} |
// comme la div qui contiendra la valeur du nombre de stations va se placer dans la page |
// au centre de la maille (et qui va servir de point d'ancrage pour le bord gauche par defaut) |
// il est necessaire de creer un decalage vers la gauche en fonction du nombre de chiffres |
var decalage = calculerDecalagePositionnementNombre(maille.nombrePoints); |
var sudMaille = maille._originalPoints[0].y, |
ouestMaille = maille._originalPoints[0].x, |
nordMaille = maille._originalPoints[2].y, |
estMaille = maille._originalPoints[2].x, |
centreMaille = new L.Point((ouestMaille + estMaille) / 2 - recul, (sudMaille + nordMaille) / 2); |
centreMaille = new L.Point((ouestMaille+estMaille)/2 - decalage, (sudMaille+nordMaille)/2); |
var divIcon = new L.divIcon({ |
className : "nombre-sites", |
html : maille.nombrePoints |
368,6 → 369,18 |
coucheSites.addLayer(marqueurDiv); |
} |
function calculerDecalagePositionnementNombre(nombrePoints) { |
var recul = 0; |
if (nombrePoints >= 10000) { |
recul = 14; |
} else if (nombrePoints >= 1000) { |
recul = 9; |
} else if (nombrePoints >= 100) { |
recul = 5; |
} |
return recul; |
} |
function clicSurMaille(event) { |
if (event.target._zIndex != null) { |
map.fitBounds(event.target.options.maille) |
376,126 → 389,160 |
} |
} |
function getColor(nbPoints) { |
if (nbPoints >= 2500) { |
return '#E74440'; |
} else if (nbPoints >= 1000) { |
return '#E75E40'; |
} else if (nbPoints >= 500) { |
return '#E77840'; |
} else if (nbPoints >= 100) { |
return '#E79240'; |
} else if (nbPoints >= 50) { |
return '#E7AC40'; |
} else if (nbPoints >= 10) { |
return '#E7C640'; |
} else { |
return '#E7E040'; |
// generer la couleur a afficher pour les mailles |
function getColor(nombrePoints) { |
var couleur = {'bleu': 231, 'vert': 224, 'rouge': 64}, |
seuils = [1, 10, 50 ,100, 500, 1000, 2500], |
pas = 26, |
position = 0; |
for (var index = 1; index < seuils.length-1 && nombrePoints >= seuils[index]; index ++) { |
position ++; |
} |
couleur.vert -= position*pas; |
return 'rgb('+couleur.bleu+','+couleur.vert+','+couleur.rouge+')'; |
/*var codeHexa = 'rgb(231,224,64)'; |
if (nombrePoints >= 2500) { |
codeHexa = 'rgb(231,68,64)'; |
} else if (nombrePoints >= 1000) { |
codeHexa = 'rgb(231,94,64)'; |
} else if (nombrePoints >= 500) { |
codeHexa = 'rgb(231,120,64)'; |
} else if (nombrePoints >= 100) { |
codeHexa = 'rgb(231,146,64)'; |
} else if (nombrePoints >= 50) { |
codeHexa = 'rgb(231,172,64)'; |
} else if (nombrePoints >= 10) { |
codeHexa = 'rgb(231,198,64)'; |
} |
return codeHexa;*/ |
} |
function ajouterPoint(feature) { |
var point = new L.LatLng(feature.geometry.coordinates[0], feature.geometry.coordinates[1]), |
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, |
type : feature.properties.typeSite, |
title : feature.properties.nom |
}).addTo(map); |
// evenement onclick sur marqueur pour recuperer les observations sur ce point |
marker.on('click', clicSurMarqueur); |
icon : icone, |
type : feature.properties.typeSite, |
title : feature.properties.nom |
}).addTo(map); |
marker.on('click', surClicMarqueur); |
coucheSites.addLayer(marker); |
} |
function afficherLegende() { |
if (legende != null) { |
return; |
} |
legende = new L.Control({position : 'bottomright'}); |
legende.onAdd = function(map) { |
var div = L.DomUtil.create('div', 'info'); |
div.innerHTML = '<h4>' + titreLegende + '</h4>'; |
var seuils = [1, 10, 50 ,100, 500, 1000, 2500]; |
var labels = []; |
for (var i = 0; i < seuils.length; i ++) { |
div.innerHTML += '<div class="legend"><i style="background:' + getColor(seuils[i] + 1) + '"></i>' + seuils[i] |
+ (i + 1 < seuils.length ? '–' + seuils[i + 1] : '+') + '</div>'; |
} |
return div; |
return construireContenuHtmlLegende(); |
}; |
map.addControl(legende); |
} |
function masquerLegende() { |
if (legende != null) { |
map.removeControl(legende); |
legende = null; |
function construireContenuHtmlLegende() { |
var div = L.DomUtil.create('div', 'info'); |
div.innerHTML = '<h4>' + titreLegende + '</h4>'; |
var seuils = [1, 10, 50 ,100, 500, 1000, 2500]; |
var labels = []; |
for (var i = 0; i < seuils.length; i ++) { |
div.innerHTML += |
'<div class="legend">'+ |
'<span style="background:' + getColor(seuils[i] + 1) + '"></span>'+ |
seuils[i]+ (i + 1 < seuils.length ? '–' + seuils[i + 1] : '+')+ |
'</div>'; |
} |
return div; |
} |
function masquerLegende() { |
map.removeControl(legende); |
legende = null; |
} |
function clicSurMarqueur(event) { |
// centrer la carte sur le marqueur |
function surClicMarqueur(event) { |
var latitude = event.target.getLatLng().lat; |
var longitude = event.target.getLatLng().lng; |
pointClique = event.target; |
afficherMessageChargement('observations'); |
// charger les observations se trouvant sur ce point |
var parametres = {"num_taxon" : num_taxon, "referentiel" : referentiel, "dept" : dept, |
"utilisateur" : utilisateur, "longitude" : longitude, "latitude" : latitude}; |
url = urlBase + source + "/observations?" + convertirEnParametresUrl(parametres); |
fonctionCallback = function(JSONtext) { |
masquerMessageChargement(); |
if (requeteChargementPoints.status != 200 && requeteChargementPoints.status != 304 |
&& typeof(JSONtext) != 'undefined') { |
alert(JSONtext); |
return; |
} |
var parametres = { |
"source" : source, |
"num_taxon" : num_taxon, |
"referentiel" : referentiel, |
"auteur" : auteur, |
"longitude" : longitude, |
"latitude" : latitude |
}; |
url = urlBase + "observations?" + convertirEnParametresUrl(parametres); |
fonctionCallback = traiterDonneesObservations; |
executerAJAX(); |
} |
function traiterDonneesObservations() { |
masquerMessageChargement(); |
var texte = requeteChargementPoints.responseText; |
if (!retourRequeteOK()) { |
alert(texte); |
} else { |
obsJSON = eval("(function(){return " + JSONtext + ";})()"); |
// vider la liste des observations de l'infobulle precedente |
while (obsStation.length > 0) { |
obsStation.pop(); |
} |
obsJSON = eval("(function(){return " + texte + ";})()"); |
viderListeObservations(); |
if (obsJSON.total > 0) { |
// centrer la vue de la carte sur la station |
map.setView(new L.LatLng(latitude, longitude), map.getZoom()); |
// afficher les observations dans une infobulle |
doitRafraichirCarte = false; |
map.setView(new L.LatLng(pointClique.getLatLng().lat, pointClique.getLatLng().lng), map.getZoom()); |
afficherInfoBulle(); |
} else if (infoBulle != null) { |
// supprimer l'infobulle |
masquerInfoBulle(); |
} |
} |
executerAJAX(); |
} |
function viderListeObservations() { |
obsStation = new Array(); |
} |
/////////////////////////////////////// |
// INFOBULLE // |
/////////////////////////////////////// |
// ==================================================================== |
// Gestion de l'infobulle |
var infoBulle = null, |
obsJSON = null, |
var obsJSON = null, |
pointClique = null, |
obsStation = [], |
typeAffichage = ""; |
function afficherInfoBulle() { |
// creer l'infobulle sur le marqueur qui a declenche l'evenement clicSurMarqueur |
var latitude = pointClique.getLatLng().lat; |
var longitude = pointClique.getLatLng().lng; |
infoBulle = new L.Popup({maxWidth : 600, maxHeight : 350}); |
infoBulle = new L.Popup({maxWidth : definirLargeurInfoBulle(), maxHeight : 350}); |
infoBulle.setLatLng(new L.LatLng(latitude, longitude)); |
// afficher la popup sur la carte |
infoBulle.setContent($("#tpl-obs").html()); |
infoBulle.openOn(map); |
// remplir le contenu de la popup |
infoBulle.openOn(map); |
remplirContenuPopup(); |
} |
function definirLargeurInfoBulle() { |
var largeurViewPort = $(window).width(); |
var lageurInfoBulle = null; |
if (largeurViewPort < 800) { |
largeurInfoBulle = 400; |
} else if (largeurViewPort >= 800 && largeurViewPort < 1200) { |
largeurInfoBulle = 500; |
} else if (largeurViewPort >= 1200) { |
largeurInfoBulle = 600; |
} |
return largeurInfoBulle; |
} |
function redimensionnerPopup() { |
$('.leaflet-popup-content*').css('width', definirLargeurInfoBulle()); |
$('#info-bulle').css('width', definirLargeurInfoBulle()); |
} |
function remplirContenuPopup() { |
ajouterTableauTriable("#obs-tableau"); |
ajouterTitre(); |
afficherOnglets(); |
/trunk/widget/modules/carto/squelettes/scripts/L.KML.js |
---|
New file |
0,0 → 1,363 |
/* |
* |
* Copyright (c) 2011-2012, Pavel Shramov |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without modification, are |
* permitted provided that the following conditions are met: |
* |
* 1. Redistributions of source code must retain the above copyright notice, this list of |
* conditions and the following disclaimer. |
* |
* 2. Redistributions in binary form must reproduce the above copyright notice, this list |
* of conditions and the following disclaimer in the documentation and/or other materials |
* provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* |
*/ |
L.KML = L.FeatureGroup.extend({ |
options: { |
async: true |
}, |
initialize: function(kml, options) { |
L.Util.setOptions(this, options); |
this._kml = kml; |
this._layers = {}; |
if (kml) { |
this.addKML(kml, options, this.options.async); |
} |
}, |
loadXML: function(url, cb, options, async) { |
if (async == undefined) async = this.options.async; |
if (options == undefined) options = this.options; |
var req = new window.XMLHttpRequest(); |
req.open('GET', url, async); |
try { |
req.overrideMimeType('text/xml'); // unsupported by IE |
} catch(e) {} |
req.onreadystatechange = function() { |
if (req.readyState != 4) return; |
if(req.status == 200) cb(req.responseXML, options); |
}; |
req.send(null); |
}, |
addKML: function(url, options, async) { |
var _this = this; |
var cb = function(gpx, options) { _this._addKML(gpx, options) }; |
this.loadXML(url, cb, options, async); |
}, |
_addKML: function(xml, options) { |
var layers = L.KML.parseKML(xml); |
if (!layers || !layers.length) return; |
for (var i = 0; i < layers.length; i++) |
{ |
this.fire('addlayer', { |
layer: layers[i] |
}); |
this.addLayer(layers[i]); |
} |
this.latLngs = L.KML.getLatLngs(xml); |
this.fire("loaded"); |
}, |
latLngs: [] |
}); |
L.Util.extend(L.KML, { |
parseKML: function (xml) { |
var style = this.parseStyle(xml); |
var el = xml.getElementsByTagName("Folder"); |
var layers = [], l; |
for (var i = 0; i < el.length; i++) { |
if (!this._check_folder(el[i])) { continue; } |
l = this.parseFolder(el[i], style); |
if (l) { layers.push(l); } |
} |
el = xml.getElementsByTagName('Placemark'); |
for (var j = 0; j < el.length; j++) { |
if (!this._check_folder(el[j])) { continue; } |
l = this.parsePlacemark(el[j], xml, style); |
if (l) { layers.push(l); } |
} |
return layers; |
}, |
// Return false if e's first parent Folder is not [folder] |
// - returns true if no parent Folders |
_check_folder: function (e, folder) { |
e = e.parentElement; |
while (e && e.tagName !== "Folder") |
{ |
e = e.parentElement; |
} |
return !e || e === folder; |
}, |
parseStyle: function (xml) { |
var style = {}; |
var sl = xml.getElementsByTagName("Style"); |
//for (var i = 0; i < sl.length; i++) { |
var attributes = {color: true, width: true, Icon: true, href: true, |
hotSpot: true}; |
function _parse(xml) { |
var options = {}; |
for (var i = 0; i < xml.childNodes.length; i++) { |
var e = xml.childNodes[i]; |
var key = e.tagName; |
if (!attributes[key]) { continue; } |
if (key === 'hotSpot') |
{ |
for (var j = 0; j < e.attributes.length; j++) { |
options[e.attributes[j].name] = e.attributes[j].nodeValue; |
} |
} else { |
var value = e.childNodes[0].nodeValue; |
if (key === 'color') { |
options.opacity = parseInt(value.substring(0, 2), 16) / 255.0; |
options.color = "#" + value.substring(2, 8); |
} else if (key === 'width') { |
options.weight = value; |
} else if (key === 'Icon') { |
ioptions = _parse(e); |
if (ioptions.href) { options.href = ioptions.href; } |
} else if (key === 'href') { |
options.href = value; |
} |
} |
} |
return options; |
} |
for (var i = 0; i < sl.length; i++) { |
var e = sl[i], el; |
var options = {}, poptions = {}, ioptions = {}; |
el = e.getElementsByTagName("LineStyle"); |
if (el && el[0]) { options = _parse(el[0]); } |
el = e.getElementsByTagName("PolyStyle"); |
if (el && el[0]) { poptions = _parse(el[0]); } |
if (poptions.color) { options.fillColor = poptions.color; } |
if (poptions.opacity) { options.fillOpacity = poptions.opacity; } |
el = e.getElementsByTagName("IconStyle"); |
if (el && el[0]) { ioptions = _parse(el[0]); } |
if (ioptions.href) { |
// save anchor info until the image is loaded |
options.icon = new L.KMLIcon({ |
iconUrl: ioptions.href, |
shadowUrl: null, |
iconAnchorRef: {x: ioptions.x, y: ioptions.y}, |
iconAnchorType: {x: ioptions.xunits, y: ioptions.yunits} |
}); |
} |
style['#' + e.getAttribute('id')] = options; |
} |
return style; |
}, |
parseFolder: function (xml, style) { |
var el, layers = [], l; |
el = xml.getElementsByTagName('Folder'); |
for (var i = 0; i < el.length; i++) { |
if (!this._check_folder(el[i], xml)) { continue; } |
l = this.parseFolder(el[i], style); |
if (l) { layers.push(l); } |
} |
el = xml.getElementsByTagName('Placemark'); |
for (var j = 0; j < el.length; j++) { |
if (!this._check_folder(el[j], xml)) { continue; } |
l = this.parsePlacemark(el[j], xml, style); |
if (l) { layers.push(l); } |
} |
if (!layers.length) { return; } |
if (layers.length === 1) { return layers[0]; } |
return new L.FeatureGroup(layers); |
}, |
parsePlacemark: function (place, xml, style) { |
var i, j, el, options = {}; |
el = place.getElementsByTagName('styleUrl'); |
for (i = 0; i < el.length; i++) { |
var url = el[i].childNodes[0].nodeValue; |
for (var a in style[url]) |
{ |
// for jshint |
if (true) |
{ |
options[a] = style[url][a]; |
} |
} |
} |
var layers = []; |
var parse = ['LineString', 'Polygon', 'Point']; |
for (j in parse) { |
// for jshint |
if (true) |
{ |
var tag = parse[j]; |
el = place.getElementsByTagName(tag); |
for (i = 0; i < el.length; i++) { |
var l = this["parse" + tag](el[i], xml, options); |
if (l) { layers.push(l); } |
} |
} |
} |
if (!layers.length) { |
return; |
} |
var layer = layers[0]; |
if (layers.length > 1) { |
layer = new L.FeatureGroup(layers); |
} |
var name, descr = ""; |
el = place.getElementsByTagName('name'); |
if (el.length) { |
name = el[0].childNodes[0].nodeValue; |
} |
el = place.getElementsByTagName('description'); |
for (i = 0; i < el.length; i++) { |
for (j = 0; j < el[i].childNodes.length; j++) { |
descr = descr + el[i].childNodes[j].nodeValue; |
} |
} |
if (name) { |
layer.bindPopup("<h2>" + name + "</h2>" + descr); |
} |
return layer; |
}, |
parseCoords: function (xml) { |
var el = xml.getElementsByTagName('coordinates'); |
return this._read_coords(el[0]); |
}, |
parseLineString: function (line, xml, options) { |
var coords = this.parseCoords(line); |
if (!coords.length) { return; } |
return new L.Polyline(coords, options); |
}, |
parsePoint: function (line, xml, options) { |
var el = line.getElementsByTagName('coordinates'); |
if (!el.length) { |
return; |
} |
var ll = el[0].childNodes[0].nodeValue.split(','); |
return new L.KMLMarker(new L.LatLng(ll[1], ll[0]), options); |
}, |
parsePolygon: function (line, xml, options) { |
var el, polys = [], inner = [], i, coords; |
el = line.getElementsByTagName('outerBoundaryIs'); |
for (i = 0; i < el.length; i++) { |
coords = this.parseCoords(el[i]); |
if (coords) { |
polys.push(coords); |
} |
} |
el = line.getElementsByTagName('innerBoundaryIs'); |
for (i = 0; i < el.length; i++) { |
coords = this.parseCoords(el[i]); |
if (coords) { |
inner.push(coords); |
} |
} |
if (!polys.length) { |
return; |
} |
if (options.fillColor) { |
options.fill = true; |
} |
if (polys.length === 1) { |
return new L.Polygon(polys.concat(inner), options); |
} |
return new L.MultiPolygon(polys, options); |
}, |
getLatLngs: function (xml) { |
var el = xml.getElementsByTagName('coordinates'); |
var coords = []; |
for (var j = 0; j < el.length; j++) { |
// text might span many childnodes |
coords = coords.concat(this._read_coords(el[j])); |
} |
return coords; |
}, |
_read_coords: function (el) { |
var text = "", coords = [], i; |
for (i = 0; i < el.childNodes.length; i++) { |
text = text + el.childNodes[i].nodeValue; |
} |
text = text.split(/[\s\n]+/); |
for (i = 0; i < text.length; i++) { |
var ll = text[i].split(','); |
if (ll.length < 2) { |
continue; |
} |
coords.push(new L.LatLng(ll[1], ll[0])); |
} |
return coords; |
} |
}); |
L.KMLIcon = L.Icon.extend({ |
createIcon: function () { |
var img = this._createIcon('icon'); |
img.onload = function () { |
var i = new Image(); |
i.src = this.src; |
this.style.width = i.width + 'px'; |
this.style.height = i.height + 'px'; |
if (this.anchorType.x === 'UNITS_FRACTION' || this.anchorType.x === 'fraction') { |
img.style.marginLeft = (-this.anchor.x * i.width) + 'px'; |
} |
if (this.anchorType.y === 'UNITS_FRACTION' || this.anchorType.x === 'fraction') { |
img.style.marginTop = (-(1 - this.anchor.y) * i.height) + 'px'; |
} |
this.style.display = ""; |
}; |
return img; |
}, |
_setIconStyles: function (img, name) { |
L.Icon.prototype._setIconStyles.apply(this, [img, name]) |
// save anchor information to the image |
img.anchor = this.options.iconAnchorRef; |
img.anchorType = this.options.iconAnchorType; |
} |
}); |
L.KMLMarker = L.Marker.extend({ |
options: { |
icon: new L.KMLIcon.Default() |
} |
}); |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/trunk/widget/modules/carto/squelettes/scripts/L.Control.Zoomslider.js |
---|
1,3 → 1,30 |
/* |
* |
* Copyright (c) 2012, Kartena AB |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are met: |
* |
* 1. Redistributions of source code must retain the above copyright notice, this |
* list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
* this list of conditions and the following disclaimer in the documentation |
* and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* |
*/ |
L.Control.Zoomslider = (function(){ |
var Knob = L.Draggable.extend({ |
/trunk/widget/modules/carto/squelettes/css/carto.css |
---|
4,7 → 4,7 |
} |
body { |
overflow:hidden; |
padding:0; |
padding:2px; |
margin:0; |
width:100%; |
height:100%; |
82,15 → 82,15 |
/*+-----------------------------------------------------------------------------------------------------------------+*/ |
/* Tableau : tablesorter */ |
th.header { |
background:url(../images/trie.png) no-repeat center right; |
background:url(../images/tri.png) no-repeat center right; |
padding-right:20px; |
} |
th.headerSortUp { |
background:url(../images/trie_croissant.png) no-repeat center right #56B80E; |
background:url(../images/tri_croissant.png) no-repeat center right #56B80E; |
color:white; |
} |
th.headerSortDown { |
background:url(../images/trie_decroissant.png) no-repeat center right #56B80E; |
background:url(../images/tri_decroissant.png) no-repeat center right #56B80E; |
color:white; |
} |
/*+-----------------------------------------------------------------------------------------------------------------+*/ |
461,4 → 461,40 |
color: white; |
white-space: pre-wrap; |
width: 300px; |
} |
/*+------------------------------------------------------------------- |
/* Ajout alex */ |
.info { |
padding:6px 8px; |
font-size:1em; |
background:white; |
width:100px; |
box-shadow:0 0 15px black; |
border-radius:5px; |
line-height:18px; |
} |
.info h4 { |
font-size: 15px; |
margin: 0 0 5px; |
color: #555; |
} |
.legend { |
padding :3px; |
color:#999; |
} |
.legend span { |
width:18px; |
height:18px; |
float:left; |
margin-right:8px; |
opacity: 0.7; |
} |
.nombre-sites { |
font-size:13px; |
font-family:sans-serif; |
text-align:center; |
color:black; |
} |
/trunk/widget/modules/carto/squelettes/carto.tpl.html |
---|
20,19 → 20,6 |
<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" /> |
<link href="<?=$url_base?>modules/carto/squelettes/css/carto.css" rel="stylesheet" type="text/css" media="screen" /> |
<style type="text/css"> |
<!-- |
#body {margin: 0; padding: 2px;} |
#map { margin: 1px solid black;} |
.info { padding: 6px 8px; font-size: 13px; background: white; width: 100px; |
box-shadow: 0 0 15px black; border-radius: 5px; line-height: 18px; } |
.info h4 { font-size: 15px; margin: 0 0 5px; color: #555; } |
.legend { padding : 3px; color: #999; } |
.legend i { width: 18px; height: 18px; float: left; margin-right: 8px; opacity: 0.7; } |
.nombre-sites { font-size: 13px; font-family: sans-serif; text-align: center; |
color : black; } |
--> |
</style> |
<!-- Javascript : bibliothèques --> |
<script src="http://cdn.leafletjs.com/leaflet-0.5/leaflet.js"></script> |
40,15 → 27,15 |
<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://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script> |
<script type="text/javascript"> |
<script type="text/javascript"> |
//<![CDATA[ |
var source = '<?= $source ?>', |
num_taxon = '<?= $num_taxon ?>', |
dept = '<?= $departement ?>', |
utilisateur = '<?= $utilisateur ?>', |
auteur = '<?= $auteur ?>', |
referentiel = '<?= $referentiel ?>', |
urlBase = '<?= $url_serivce_carto ?>/moissonnage/', |
urlsLimitesCommunales = <?= $url_limites_communales ?>, |
urlBase = '<?= $url_serivce_carto ?>/projets/', |
urlsLimitesCommunales = <?= $urlLimitesCommunales ?>, |
communeImageUrl = '<?= $communeImageUrl ?>', |
pointImageUrl = '<?= $pointImageUrl ?>', |
liensVersSources = '<?= $liensVersSources ?>'.split(','), |
58,7 → 45,7 |
//]]> |
</script> |
<script src="http://maps.google.com/maps/api/js?v=3.5&sensor=true&language=fr®ion=FR" type="text/javascript"></script> |
<script src="<?=$url_base?>modules/carto/squelettes/scripts/layer/vector/KML.js" type="text/javascript"></script> |
<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> |
</head> |
/trunk/widget/modules/carto/squelettes |
---|
Property changes: |
Added: svn:ignore |
+kml |