Subversion Repositories eFlore/Applications.cel

Rev

Rev 1037 | Rev 1041 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1037 Rev 1039
Line 2... Line 2...
2
// PARAMÊTRES et CONSTANTES
2
// PARAMÊTRES et CONSTANTES
3
// Mettre à true pour afficher les messages de débogage
3
// Mettre à true pour afficher les messages de débogage
4
var DEBUG = false; 
4
var DEBUG = false; 
5
var communeImageUrl = 'http://www.tela-botanica.org/commun/icones/carto/commune.png';
5
var communeImageUrl = 'http://www.tela-botanica.org/commun/icones/carto/commune.png';
6
var pointImageUrl = 'http://www.tela-botanica.org/commun/icones/carto/point2.png';
6
var pointImageUrl = 'http://www.tela-botanica.org/commun/icones/carto/point2.png';
7
var groupeImageUrlTpl = 'http://localhost/service:cel:CelWidgetMap/icone-groupe?type={type}&nbre={nbre}'
7
var groupeImageUrlTpl = 'http://www.tela-botanica.org/service:cel:CelWidgetMap/icone-groupe?type={type}&nbre={nbre}'
8
var pointsOrigine = null;
8
var pointsOrigine = null;
9
var boundsOrigine = null;
9
var boundsOrigine = null;
10
var markerClusterer = null;
10
var markerClusterer = null;
11
var map = null;
11
var map = null;
12
var infoBulle = new google.maps.InfoWindow();
12
var infoBulle = new google.maps.InfoWindow();
Line 70... Line 70...
70
/*+--------------------------------------------------------------------------------------------------------+*/
70
/*+--------------------------------------------------------------------------------------------------------+*/
71
// AFFICHAGE GÉNÉRAL
71
// AFFICHAGE GÉNÉRAL
Line 72... Line 72...
72
 
72
 
73
function afficherTitreCarte() {
73
function afficherTitreCarte() {
-
 
74
	if (stations != null && taxonsCarte.length > 0) {
74
	if (stations != null && taxonsCarte.length > 0) {
75
		var obsNbre = stations.stats.observations;
-
 
76
		var obsNbreFormate = stations.stats.observations.formaterNombre();
75
		var obsNbre = stations.stats.observations.formaterNombre();
77
		var plteNbre = taxonsCarte.length;
-
 
78
		var plteNbreFormate = taxonsCarte.length.formaterNombre();
76
		var plteNbre = taxonsCarte.length.formaterNombre();
79
		var communeNbre = stations.stats.communes;
Line 77... Line 80...
77
		var communeNbre = stations.stats.communes.formaterNombre();
80
		var communeNbreFormate = stations.stats.communes.formaterNombre();
78
	
81
	
Line 79... Line 82...
79
		var titre = obsNbre+' observation';
82
		var titre = obsNbreFormate+' observation';
80
		titre += (obsNbre > 1) ? 's' : '' ;
83
		titre += (obsNbre > 1) ? 's' : '' ;
81
		
84
		
82
		if (nt == '*') {
85
		if (nt == '*') {
83
			titre += ' de '+plteNbre+' plante';
86
			titre += ' de '+plteNbreFormate+' plante';
84
			titre += (plteNbre > 1) ? 's' : '' ;
87
			titre += (plteNbre > 1) ? 's' : '' ;
85
		} else {
88
		} else {
86
			if (taxonsCarte[0]) {
89
			if (taxonsCarte[0]) {
87
				var taxon = taxonsCarte[0];
90
				var taxon = taxonsCarte[0];
Line 88... Line 91...
88
				titre += ' pour '+taxon.nom;
91
				titre += ' pour '+taxon.nom;
89
			}
92
			}
Line 90... Line 93...
90
		}
93
		}
91
		
94
		
92
		titre += ' sur '+communeNbre+' commune';
95
		titre += ' sur '+communeNbreFormate+' commune';
Line 133... Line 136...
133
 
136
 
134
function chargerLimitesCommunales() {
137
function chargerLimitesCommunales() {
135
	if (urlsLimitesCommunales != null) {
138
	if (urlsLimitesCommunales != null) {
136
		for (urlId in urlsLimitesCommunales) { 
139
		for (urlId in urlsLimitesCommunales) { 
137
			var url = urlsLimitesCommunales[urlId];
140
			var url = urlsLimitesCommunales[urlId];
138
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true});
141
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: false});
139
			ctaLayer.setMap(map);
142
			ctaLayer.setMap(map);
140
		}
143
		}
141
	}
144
	}
-
 
145
}
142
}
146
 
143
var listener = null;
147
var listener = null;
144
var timer = null;
148
var timer = null;
145
function attribuerListenerCarte() {
149
function attribuerListenerCarte() {
146
	listener = google.maps.event.addListener(map, 'bounds_changed', function(){
150
	listener = google.maps.event.addListener(map, 'bounds_changed', function(){
Line 157... Line 161...
157
	if(requeteChargementPoints != null) {
161
	if(requeteChargementPoints != null) {
158
		requeteChargementPoints.abort();
162
		requeteChargementPoints.abort();
159
	}
163
	}
160
	timer = window.setTimeout(function() {
164
	timer = window.setTimeout(function() {
161
		var zoom = map.getZoom();
165
		var zoom = map.getZoom();
162
		// ajout d'un facteur de correction pour charger légerement plus que nécessaire pour stabiliser les points
-
 
163
		// à voir si c'est efficace
-
 
164
		var facteurCorrection = 0.5;
-
 
165
		var NELatLng = (map.getBounds().getNorthEast().lat()+facteurCorrection)+'|'+(map.getBounds().getNorthEast().lng()+facteurCorrection);
166
		var NELatLng = (map.getBounds().getNorthEast().lat())+'|'+(map.getBounds().getNorthEast().lng());
166
		var SWLatLng = (map.getBounds().getSouthWest().lat()-facteurCorrection)+'|'+(map.getBounds().getSouthWest().lng()-facteurCorrection);
167
		var SWLatLng = (map.getBounds().getSouthWest().lat())+'|'+(map.getBounds().getSouthWest().lng());
167
		chargerMarqueurs(zoom, NELatLng, SWLatLng);
168
		chargerMarqueurs(zoom, NELatLng, SWLatLng);
168
    }, 400);		
169
    }, 400);		
169
}
170
}
Line 170... Line -...
170
 
-
 
171
var premierChargement = true;
171
 
172
var marqueurs = new Array();
172
var marqueurs = new Array();
173
function chargerMarqueurs(zoom, NELatLng, SWLatLng) {
173
function chargerMarqueurs(zoom, NELatLng, SWLatLng) {
174
	var url = stationsUrl+
174
	var url = stationsUrl+
175
		'&zoom='+zoom+
175
		'&zoom='+zoom+
Line 209... Line 209...
209
	stations = data;
209
	stations = data;
210
	afficherTitreCarte();
210
	afficherTitreCarte();
Line 211... Line 211...
211
	
211
	
212
	$.each(stations.points, function (index, station) {		
212
	$.each(stations.points, function (index, station) {		
213
		if(station != null) {
213
		if(station != null) {
-
 
214
			var nouveauMarqueur = creerMarqueur(station);
214
			marqueurs.push(creerMarqueur(station));
215
			marqueurs.push(nouveauMarqueur);
215
		}
216
		}
216
	});
217
	});
Line 217... Line 218...
217
}
218
}
Line 238... Line 239...
238
	attribuerListenerClick(marqueur, station['id']);
239
	attribuerListenerClick(marqueur, station['id']);
239
	marqueur.setMap(map);
240
	marqueur.setMap(map);
240
    return marqueur;
241
    return marqueur;
241
}
242
}
Line -... Line 243...
-
 
243
 
-
 
244
function rendrePointsVisibles(bounds) {
-
 
245
	map.setCenter(bounds.getCenter());
-
 
246
	map.fitBounds(bounds);
-
 
247
	map.panToBounds(bounds);
-
 
248
}
242
 
249
 
Line 243... Line 250...
243
function programmerRafraichissementCarteSauv() {
250
function programmerRafraichissementCarteSauv() {
244
	
251
	
245
	var points = [];
252
	var points = [];
Line 314... Line 321...
314
		google.maps.event.addListener(marqueur, 'click', surClickGroupe);
321
		google.maps.event.addListener(marqueur, 'click', surClickGroupe);
315
	}
322
	}
316
}
323
}
Line 317... Line 324...
317
 
324
 
318
function surClickMarqueur(event) {
325
function surClickMarqueur(event) {
-
 
326
 
-
 
327
	if(infoBulleOuverte) {
-
 
328
	    infoBulle.close();
-
 
329
	}
319
	
330
  
320
	pointClique = this;
331
	pointClique = this;
321
	infoBulle.open(map, this);
332
	infoBulle.open(map, this);
Line 322... Line 333...
322
	actualiserPagineur();
333
	actualiserPagineur();
Line 465... Line 476...
465
		creerTitreInfoBulle();
476
		creerTitreInfoBulle();
466
		selectionnerOnglet("#obs-vue-"+pagineur.format);
477
		selectionnerOnglet("#obs-vue-"+pagineur.format);
467
		surClicPagePagination(0, null);
478
		surClicPagePagination(0, null);
468
	}
479
	}
Line 469... Line -...
469
	
-
 
470
	if (pagineur.limite < total) {
480
	
471
		afficherPagination();
-
 
472
	}
481
	afficherPagination();
473
	actualiserPagineur();
482
	actualiserPagineur();
Line 474... Line 483...
474
}
483
}
475
 
484