4,7 → 4,7 |
var DEBUG = false; |
var communeImageUrl = 'http://www.tela-botanica.org/commun/icones/carto/commune.png'; |
var pointImageUrl = 'http://www.tela-botanica.org/commun/icones/carto/point2.png'; |
var groupeImageUrlTpl = 'http://localhost/jrest/CelWidgetMap/icone-groupe?type={type}&nbre={nbre}' |
var groupeImageUrlTpl = 'http://localhost/service:cel:CelWidgetMap/icone-groupe?type={type}&nbre={nbre}' |
var pointsOrigine = null; |
var boundsOrigine = null; |
var markerClusterer = null; |
45,6 → 45,7 |
var mgr = null; |
var marqueursCache = new Array(); |
var zonesCache = new Array(); |
var requeteChargementPoints; |
/*+--------------------------------------------------------------------------------------------------------+*/ |
// INITIALISATION DU CODE |
|
152,7 → 153,10 |
function programmerRafraichissementCarte() { |
if(timer != null) { |
window.clearTimeout(timer); |
} |
} |
if(requeteChargementPoints != null) { |
requeteChargementPoints.abort(); |
} |
timer = window.setTimeout(function() { |
var zoom = map.getZoom(); |
var NELatLng = map.getBounds().getNorthEast().lat()+'|'+map.getBounds().getNorthEast().lng(); |
161,10 → 165,6 |
}, 400); |
} |
|
function collecterBorduresEtChargerMarqueurs() { |
|
} |
|
var premierChargement = true; |
var marqueurs = new Array(); |
function chargerMarqueurs(zoom, NELatLng, SWLatLng) { |
177,24 → 177,41 |
return; |
} |
|
$.getJSON(url, function(data) { |
|
$.each(marqueurs, function(index, marqueur) { |
marqueur.setMap(null); |
}); |
marqueurs = new Array(); |
|
stations = data; |
afficherTitreCarte(); |
|
$.each(stations.points, function (index, station) { |
if(station != null) { |
marqueurs.push(creerMarqueur(station)); |
} |
}); |
if(requeteChargementPoints != null) { |
requeteChargementPoints.abort(); |
} |
|
afficherMessageChargementPoints(); |
requeteChargementPoints = $.getJSON(url, function(data) { |
rafraichirMarqueurs(data); |
cacherMessageChargementPoints(); |
}); |
} |
|
function afficherMessageChargementPoints() { |
$('#zone-chargement-point').css('display','block'); |
} |
|
function cacherMessageChargementPoints() { |
$('#zone-chargement-point').css('display','none'); |
} |
|
function rafraichirMarqueurs(data) { |
$.each(marqueurs, function(index, marqueur) { |
marqueur.setMap(null); |
}); |
marqueurs = new Array(); |
|
stations = data; |
afficherTitreCarte(); |
|
$.each(stations.points, function (index, station) { |
if(station != null) { |
marqueurs.push(creerMarqueur(station)); |
} |
}); |
} |
|
function creerMarqueur(station) { |
var titre = station['nbreMarqueur']; |
var icone = attribuerImageMarqueur(station['id'], station['nbreMarqueur']); |
287,11 → 304,18 |
} |
|
function surClickMarqueur(event) { |
pointClique = this; |
|
pointClique = this; |
infoBulle.open(map, this); |
actualiserPagineur(); |
|
var limites = map.getBounds(); |
var centre = limites.getCenter(); |
var nordEst = limites.getNorthEast(); |
var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng()); |
map.panTo(centreSudLatLng); |
|
afficherInfoBulle(); |
programmerRafraichissementCarte(); |
} |
|
function surClickGroupe() { |
367,6 → 391,7 |
var largeur = definirLargeurInfoBulle(); |
obsHtml = obsHtml.replace(/\{largeur\}/, largeur); |
infoBulle.setContent(obsHtml); |
chargerObs(0, 0); |
infoBulleOuverte = true; |
} |
|
389,6 → 414,10 |
} |
} |
|
function afficherMessageChargementTitreInfoBulle() { |
$("#obs-station-titre").text("Chargement des observations"); |
} |
|
function supprimerMessageChargement() { |
$('#chargement').remove(); |
} |
397,9 → 426,10 |
if (depart == 0 || depart < total) { |
var limite = 300; |
if (depart == 0) { |
obsStation = new Array(); |
obsStation = new Array(); |
surClicPagePagination(0, null); |
} |
//console.log("Chargement de "+depart+" à "+(depart+limite)); |
|
var urlObs = observationsUrl+'&start={start}&limit='+limite; |
urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationInfos.id); |
urlObs = urlObs.replace(/\{nt\}/g, nt); |
407,22 → 437,46 |
|
$.getJSON(urlObs, function(observations){ |
obsStation = obsStation.concat(observations.observations); |
chargerObs(depart+limite, pointClique.stationInfos.nbre); |
if (depart == 0) { |
actualiserInfosStation(observations); |
actualiserPagineur(); |
creerTitreInfoBulle(); |
} |
chargerObs(depart+limite, observations.total); |
}); |
} else { |
if (pagineur.limite < total) { |
afficherPagination(); |
surClicPagePagination(0, null); |
} else { |
surClicPagePagination(0, null); |
selectionnerOnglet("#obs-vue-"+pagineur.format); |
} |
selectionnerOnglet("#obs-vue-"+pagineur.format); |
surClicPagePagination(0, null); |
} |
} |
|
function actualiserInfosStation(infos) { |
pointClique.stationInfos.commune = infos.commune; |
pointClique.stationInfos.obsNbre = infos.total; |
} |
|
function creerTitreInfoBulle() { |
$("#obs-total").text(station.obsNbre); |
$("#obs-commune").text(station.commune); |
var titre = ''; |
titre += pointClique.stationInfos.obsNbre+' observation'; |
titre += (pointClique.stationInfos.obsNbre > 1) ? 's': '' ; |
titre += ' pour '; |
if (etreMarqueurCommune(pointClique.stationInfos.id)) { |
nomStation = 'la commune : '; |
} else { |
nomStation = 'la station : '; |
} |
titre += pointClique.stationInfos.nom; |
$("#obs-station-titre").text(titre); |
} |
|
function actualiserPagineur() { |
pagineur.stationId = pointClique.stationInfos.id; |
pagineur.total = pointClique.stationInfos.nbre; |
pagineur.total = pointClique.stationInfos.obsNbre; |
if (pagineur.total > 4) { |
pagineur.format = 'tableau'; |
} else { |
470,22 → 524,7 |
} |
} |
|
function afficherTitreInfoBulle() { |
var titre = ''; |
titre += pointClique.stationInfos.nbre+' observation'; |
titre += (pointClique.stationInfos.nbre > 1) ? 's': '' ; |
titre += ' pour '; |
if (etreMarqueurCommune(pointClique.stationInfos.id)) { |
nomStation = 'la commune : '; |
} else { |
nomStation = 'la station : '; |
} |
titre += pointClique.stationInfos.nom; |
$("#obs-station-titre").text(titre); |
} |
|
function initialiserContenuInfoBulle() { |
afficherTitreInfoBulle(); |
afficherMessageChargement('#observations'); |
cacherContenuOnglets(); |
afficherOnglets(); |
806,13 → 845,21 |
$('#taxon-'+nt).removeClass('taxon-actif'); |
if (nt == ntAFiltrer) { |
nt = '*'; |
executerMarkerClusterer(pointsOrigine, boundsOrigine); |
//executerMarkerClusterer(pointsOrigine, boundsOrigine); |
} else { |
var url = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer); |
$.getJSON(url, function (stationsFiltrees) { |
stationsUrl = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer); |
url = stationsUrl; |
var zoom = map.getZoom(); |
var NELatLng = map.getBounds().getNorthEast().lat()+'|'+map.getBounds().getNorthEast().lng(); |
var SWLatLng = map.getBounds().getSouthWest().lat()+'|'+map.getBounds().getSouthWest().lng(); |
url += '&zoom='+zoom+ |
'&ne='+NELatLng+ |
'&sw='+SWLatLng; |
requeteChargementPoints = $.getJSON(url, function (stationsFiltrees) { |
stations = stationsFiltrees; |
nt = ntAFiltrer; |
$('#taxon-'+nt).addClass('taxon-actif'); |
rafraichirMarqueurs(stations); |
}); |
} |
}; |