Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 953 Rev 980
Line 1... Line 1...
1
/*+--------------------------------------------------------------------------------------------------------+*/
1
/*+--------------------------------------------------------------------------------------------------------+*/
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 pointImageUrl = 'http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png';
6
var pointImageUrl = 'http://www.tela-botanica.org/commun/icones/carto/point2.png';
-
 
7
var groupeImageUrlTpl = 'http://localhost/cel-jrest/CelWidgetMap/icone-groupe?type={type}&nbre={nbre}'
6
var pointsOrigine = null;
8
var pointsOrigine = null;
7
var boundsOrigine = null;
9
var boundsOrigine = null;
8
var markerClusterer = null;
10
var markerClusterer = null;
9
var map = null;
11
var map = null;
10
var infoBulle = new google.maps.InfoWindow();
12
var infoBulle = new google.maps.InfoWindow();
-
 
13
var stations = null;
11
var pointClique = null;
14
var pointClique = null;
12
var carteCentre = new google.maps.LatLng(46.4, 3.10);
15
var carteCentre = new google.maps.LatLng(25, 10);
13
var carteOptions = {
16
var carteOptions = {
14
	zoom: 6,
17
	zoom: 3,
-
 
18
	center:carteCentre,
15
	mapTypeId: google.maps.MapTypeId.ROADMAP,
19
	mapTypeId: google.maps.MapTypeId.ROADMAP,
16
	mapTypeControlOptions: {
20
	mapTypeControlOptions: {
17
		mapTypeIds: ['OSM', 
21
		mapTypeIds: ['OSM', 
18
		             google.maps.MapTypeId.ROADMAP, 
22
		             google.maps.MapTypeId.ROADMAP, 
19
		             google.maps.MapTypeId.HYBRID, 
23
		             google.maps.MapTypeId.HYBRID, 
20
		             google.maps.MapTypeId.SATELLITE, 
24
		             google.maps.MapTypeId.SATELLITE, 
21
		             google.maps.MapTypeId.TERRAIN]
25
		             google.maps.MapTypeId.TERRAIN]
22
	}
26
	}
23
};			
27
};			
24
var ctaLayer = null;
-
 
25
var osmMapType = new google.maps.ImageMapType({
28
var osmMapType = new google.maps.ImageMapType({
26
	getTileUrl: function(coord, zoom) {
29
	getTileUrl: function(coord, zoom) {
27
		return "http://tile.openstreetmap.org/" +
30
		return "http://tile.openstreetmap.org/" +
28
		zoom + "/" + coord.x + "/" + coord.y + ".png";
31
		zoom + "/" + coord.x + "/" + coord.y + ".png";
29
	},
32
	},
Line 31... Line 34...
31
	isPng: true,
34
	isPng: true,
32
	alt: "OpenStreetMap",
35
	alt: "OpenStreetMap",
33
	name: "OSM",
36
	name: "OSM",
34
	maxZoom: 19
37
	maxZoom: 19
35
});
38
});
-
 
39
var ctaLayer = null;
36
var pagineur = {'limite':50, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
40
var pagineur = {'limite':50, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
37
var station = {'commune':'', 'obsNbre':0};
41
var station = {'commune':'', 'obsNbre':0};
38
var obsStation = new Array();
42
var obsStation = new Array();
39
var obsPage = new Array();
43
var obsPage = new Array();
40
var taxonsCarte = new Array();
44
var taxonsCarte = new Array();
-
 
45
var mgr = null;
-
 
46
var marqueursCache = new Array();
-
 
47
var zonesCache = new Array();
41
/*+--------------------------------------------------------------------------------------------------------+*/
48
/*+--------------------------------------------------------------------------------------------------------+*/
42
// INITIALISATION DU CODE
49
// INITIALISATION DU CODE
Line 43... Line 50...
43
 
50
 
44
//Déclenchement d'actions quand JQuery et le document HTML sont OK
51
//Déclenchement d'actions quand JQuery et le document HTML sont OK
45
$(document).ready(function() {
52
$(document).ready(function() {
46
	initialiserWidget();
53
	initialiserWidget();
Line 47... Line 54...
47
});
54
});
48
 
55
 
49
function initialiserWidget() {
56
function initialiserWidget() {
50
	afficherStats();
57
	definirTailleTitre();
51
	initialiserAffichageCarte();
-
 
52
	initialiserAffichagePanneauLateral();
58
	initialiserAffichageCarte();
-
 
59
	initialiserAffichagePanneauLateral();
53
	
60
	initialiserCarte();
54
	initialiserCarte();
61
	initialiserGestionnaireMarqueurs()
55
	initialiserInfoBulle();
62
	initialiserInfoBulle();
56
	initialiserFormulaireContact();
63
	initialiserFormulaireContact();
57
	chargerLimitesCommunales();
64
	chargerLimitesCommunales();
Line 58... Line 65...
58
	rafraichirCarte();
65
	rafraichirCarte();
59
}
66
}
Line 60... Line 67...
60
 
67
 
-
 
68
/*+--------------------------------------------------------------------------------------------------------+*/
61
/*+--------------------------------------------------------------------------------------------------------+*/
69
// AFFICHAGE GÉNÉRAL
-
 
70
 
62
// AFFICHAGE GÉNÉRAL
71
function afficherTitreCarte() {
-
 
72
	if (stations != null && taxonsCarte.length > 0) {
63
 
73
		var obsNbre = stations.stats.observations.formaterNombre();
-
 
74
		var plteNbre = taxonsCarte.length.formaterNombre();
-
 
75
		var communeNbre = stations.stats.communes.formaterNombre();
-
 
76
	
-
 
77
		var titre = obsNbre+' observation';
-
 
78
		titre += (obsNbre > 1) ? 's' : '' ;
-
 
79
		
-
 
80
		if (nt == '*') {
-
 
81
			titre += ' de '+plteNbre+' plante';
-
 
82
			titre += (plteNbre > 1) ? 's' : '' ;
-
 
83
		} else {
-
 
84
			if (taxonsCarte[0]) {
-
 
85
				var taxon = taxonsCarte[0];
-
 
86
				titre += ' pour '+taxon.nom;
-
 
87
			}
-
 
88
		}
-
 
89
		
-
 
90
		titre += ' sur '+communeNbre+' commune';
-
 
91
		titre += (communeNbre > 1) ? 's' : '' ;
-
 
92
		
-
 
93
		$('#carte-titre-infos').text(titre);
-
 
94
	}
-
 
95
}
-
 
96
 
-
 
97
function definirTailleTitre() {
-
 
98
	var largeurViewPort = $(window).width();
-
 
99
	var taille = null;
-
 
100
	if (largeurViewPort < 400) {
-
 
101
		taille = '0.8';
-
 
102
	} else if (largeurViewPort >= 400 && largeurViewPort < 800) {
64
function afficherStats() {
103
		taille = '1.0';
65
	// Ajout du nombre de communes où des observations ont eu lieu
104
	} else if (largeurViewPort >= 800) {
Line 66... Line 105...
66
	$('#commune-nbre').text(stations.stats.communes.formaterNombre());
105
		taille = '1.6';
67
	// Ajout du nombre d'observations
106
	}
Line 68... Line 107...
68
	$('#obs-nbre').text(stations.stats.observations.formaterNombre());
107
	$("#carte-titre").css('font-size', taille+'em');
69
}
108
}
70
 
109
 
71
/*+--------------------------------------------------------------------------------------------------------+*/
110
/*+--------------------------------------------------------------------------------------------------------+*/
72
// CARTE
111
// CARTE
73
 
112
 
74
function initialiserAffichageCarte() {
113
function initialiserAffichageCarte() {
75
	$('#carte').height($(window).height() - 35);
114
	$('#carte').height($(window).height() - 35);
Line 84... Line 123...
84
	map = new google.maps.Map(document.getElementById('carte'), carteOptions);
123
	map = new google.maps.Map(document.getElementById('carte'), carteOptions);
85
	// Ajout de la couche OSM à la carte
124
	// Ajout de la couche OSM à la carte
86
	map.mapTypes.set('OSM', osmMapType);
125
	map.mapTypes.set('OSM', osmMapType);
87
}
126
}
Line -... Line 127...
-
 
127
 
-
 
128
function initialiserGestionnaireMarqueurs() {
-
 
129
	mgr = new MarkerManager(map);
Line 88... Line 130...
88
 
130
}
89
 
131
 
90
function chargerLimitesCommunales() {
132
function chargerLimitesCommunales() {
91
	if (urlsLimitesCommunales != null) {
133
	if (urlsLimitesCommunales != null) {
92
		for (urlId in urlsLimitesCommunales) { 
134
		for (urlId in urlsLimitesCommunales) { 
93
			var url = urlsLimitesCommunales[urlId];
135
			var url = urlsLimitesCommunales[urlId];
94
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true});
136
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true});
95
			ctaLayer.setMap(map);
137
			ctaLayer.setMap(map);
96
		}
138
		}
97
	}
-
 
-
 
139
	}
-
 
140
}
98
}
141
var listener = null;
-
 
142
var timer = null;
-
 
143
function rafraichirCarte() {
-
 
144
	
-
 
145
	listener = google.maps.event.addListener(map, 'bounds_changed', function(){
-
 
146
		
-
 
147
		if(timer != null) {
-
 
148
	        window.clearTimeout(timer);
-
 
149
	    }
-
 
150
	   
-
 
151
		timer = window.setTimeout(function() {
-
 
152
			var zoom = map.getZoom();
-
 
153
			var NELatLng = map.getBounds().getNorthEast().lat()+'|'+map.getBounds().getNorthEast().lng();
-
 
154
			var SWLatLng = map.getBounds().getSouthWest().lat()+'|'+map.getBounds().getSouthWest().lng();
-
 
155
			chargerMarqueurs(zoom, NELatLng, SWLatLng);
-
 
156
	    }, 300);		
-
 
157
	});
-
 
158
}
-
 
159
 
-
 
160
function collecterBorduresEtChargerMarqueurs() {
-
 
161
 
-
 
162
}
-
 
163
 
-
 
164
var premierChargement = true;
-
 
165
var marqueurs = new Array();
-
 
166
function chargerMarqueurs(zoom, NELatLng, SWLatLng) {
-
 
167
	google.maps.event.removeListener(listener);
-
 
168
	var url = stationsUrl+
-
 
169
		'&zoom='+zoom+
-
 
170
		'&ne='+NELatLng+
-
 
171
		'&sw='+SWLatLng;
-
 
172
	
-
 
173
	$.getJSON(url, function(data) {
-
 
174
		
-
 
175
		$.each(marqueurs, function(index, marqueur) {
-
 
176
			marqueur.setMap(null);
-
 
177
		});
-
 
178
		marqueurs = new Array();
-
 
179
		
-
 
180
		stations = data;
-
 
181
		afficherTitreCarte();
-
 
182
		/*if(premierChargement) {
-
 
183
			var bounds = new google.maps.LatLngBounds();
-
 
184
		}*/
-
 
185
		
-
 
186
		$.each(stations.points, function (index, station) {
-
 
187
			
-
 
188
			/*if(premierChargement) {
-
 
189
				var maLatLng = null;
-
 
190
				maLatLng = new google.maps.LatLng(station['lat'], station['lng']);
-
 
191
				bounds.extend(maLatLng);
-
 
192
			}*/
-
 
193
			
-
 
194
			if(station != null) {
-
 
195
				marqueurs.push(creerMarqueur(station));
-
 
196
			}
-
 
197
        });
-
 
198
		
-
 
199
		/*if(premierChargement) {
-
 
200
			map.fitBounds(bounds);
-
 
201
			premierChargement = false;
-
 
202
		}*/
-
 
203
		rafraichirCarte();
-
 
204
	});
-
 
205
}
-
 
206
 
-
 
207
function creerMarqueur(station) {
-
 
208
	var titre = station['nbreMarqueur'];
-
 
209
	var icone = attribuerImageMarqueur(station['id'], station['nbreMarqueur']);
-
 
210
	var latLng = new google.maps.LatLng(station['lat'], station['lng']);
-
 
211
	var marqueur = new google.maps.Marker({
-
 
212
		position: latLng,
-
 
213
		icon: icone,
-
 
214
		title: ''+titre,
-
 
215
		map: map,
-
 
216
		stationInfos: station
-
 
217
	});
-
 
218
	attribuerListenerClick(marqueur, station['id']);
-
 
219
	marqueur.setMap(map);
-
 
220
    return marqueur;
-
 
221
}
-
 
222
 
99
 
223
function rafraichirCarteSauv() {
100
function rafraichirCarte() {
224
	
101
	var points = [];
225
	var points = [];
-
 
226
	var bounds = new google.maps.LatLngBounds();
102
	var bounds = new google.maps.LatLngBounds();
227
	for (var i = 0; i < stations.points.length; ++i) {
103
	for (var i = 0; i < stations.stats.communes; ++i) {
228
		var point = stations.points[i];
104
		var maLatLng = new google.maps.LatLng(stations.points[i].coord_x, stations.points[i].coord_y);
229
		var maLatLng = new google.maps.LatLng(point.lat, point.lng);
105
		var pointImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(24, 32));
230
		var stationImage = attribuerImageMarqueur(point.id); 
106
		var point = new google.maps.Marker({
231
		var point = new google.maps.Marker({
107
			position: maLatLng,
232
			position: maLatLng,
108
			map: map,
233
			map: map,
109
			icon: pointImage,
234
			icon: stationImage,
110
			stationId: stations.points[i].id
-
 
111
		});
235
			stationInfos: point
112
 
-
 
113
		bounds.extend(maLatLng);
236
		});
114
		
-
 
115
		google.maps.event.addListener(point, 'click', function() {
-
 
116
			pointClique =  this;
-
 
117
			infoBulle.open(map, this);
-
 
118
			
-
 
119
			var limites = map.getBounds();
-
 
120
			var centre = limites.getCenter();
-
 
121
			var nordEst = limites.getNorthEast();
-
 
122
			var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
-
 
123
			map.panTo(centreSudLatLng);
-
 
124
			
-
 
125
			afficherInfoBulle();
-
 
126
			chargerObs(0, 0);
-
 
127
		});
237
		bounds.extend(maLatLng);
128
		
238
		google.maps.event.addListener(point, 'click', surClickMarqueur);
Line 129... Line 239...
129
		points.push(point);
239
		points.push(point);
130
	}
240
	}
Line 135... Line 245...
135
	}
245
	}
Line 136... Line 246...
136
	
246
	
137
	executerMarkerClusterer(points, bounds);
247
	executerMarkerClusterer(points, bounds);
Line -... Line 248...
-
 
248
}
-
 
249
 
-
 
250
function attribuerImageMarqueur(id, nbreMarqueur) {
-
 
251
	var marqueurImage = null;
-
 
252
	if (etreMarqueurCommune(id)) {
-
 
253
		marqueurImage = new google.maps.MarkerImage(communeImageUrl, new google.maps.Size(24, 32));
-
 
254
	} else if (etreMarqueurStation(id)) {
-
 
255
		marqueurImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(16, 16));
-
 
256
	} else if (etreMarqueurGroupe(id)) {
-
 
257
		var type = 0;
-
 
258
		var largeur = 0;
-
 
259
		var hauteur = 0;
-
 
260
		if (nbreMarqueur != null) {
-
 
261
			if (nbreMarqueur >= 2 && nbreMarqueur < 100 ) {
-
 
262
				type = '1';
-
 
263
				largeur = 53;
-
 
264
				hauteur = 52;
-
 
265
			} else if (nbreMarqueur >= 100 && nbreMarqueur < 1000 ) {
-
 
266
				type = '2';
-
 
267
				largeur = 56;
-
 
268
				hauteur = 55;
-
 
269
			} else if (nbreMarqueur >= 1000 && nbreMarqueur < 10000 ) {
-
 
270
				type = '3';
-
 
271
				largeur = 66;
-
 
272
				hauteur = 65;
-
 
273
			} else if (nbreMarqueur >= 10000 && nbreMarqueur < 20000 ) {
-
 
274
				type = '4';
-
 
275
				largeur = 78;
-
 
276
				hauteur = 77;
-
 
277
			} else if (nbreMarqueur >= 20000) {
-
 
278
				type = '5';
-
 
279
				largeur = 66;
-
 
280
				hauteur = 65;
-
 
281
			}
-
 
282
		}
-
 
283
		groupeImageUrl = groupeImageUrlTpl.replace(/\{type\}/, type);
-
 
284
		groupeImageUrl = groupeImageUrl.replace(/\{nbre\}/, nbreMarqueur);
-
 
285
		marqueurImage = new google.maps.MarkerImage(groupeImageUrl, new google.maps.Size(largeur, hauteur));
-
 
286
	}
-
 
287
	return marqueurImage
-
 
288
}
-
 
289
 
-
 
290
function attribuerListenerClick(marqueur, id) {
-
 
291
	if (etreMarqueurCommune(id) || etreMarqueurStation(id)) {
-
 
292
		google.maps.event.addListener(marqueur, 'click', surClickMarqueur);
-
 
293
	} else if (etreMarqueurGroupe(id)) {
-
 
294
		google.maps.event.addListener(marqueur, 'click', surClickGroupe);
-
 
295
	}
-
 
296
}
-
 
297
 
-
 
298
function surClickMarqueur() {
-
 
299
	pointClique =  this;
-
 
300
	infoBulle.open(map, this);
-
 
301
	//centrerInfoBulle();
-
 
302
	actualiserPagineur();
-
 
303
	afficherInfoBulle();
-
 
304
	chargerObs(0, 0);
-
 
305
}
-
 
306
 
-
 
307
function surClickGroupe() {
-
 
308
	map.setCenter(this.getPosition());
-
 
309
	var nouveauZoom = map.getZoom() + 2;
-
 
310
	map.setZoom(nouveauZoom);
-
 
311
	mgr.clearMarkers();
-
 
312
}
-
 
313
 
-
 
314
function etreMarqueurGroupe(id) {
-
 
315
	var groupe = false;
-
 
316
	var motif = /^GROUPE/;
-
 
317
	if (motif.test(id)) {
-
 
318
		groupe = true;
-
 
319
	}
-
 
320
	return groupe;
-
 
321
}
-
 
322
 
-
 
323
function etreMarqueurCommune(id) {
-
 
324
	var commune = false;
-
 
325
	var motif = /^COMMUNE:/;
-
 
326
	if (motif.test(id)) {
-
 
327
		commune = true;
-
 
328
	}
-
 
329
	return commune;
-
 
330
}
-
 
331
 
-
 
332
function etreMarqueurStation(id) {
-
 
333
	var station = false;
-
 
334
	var motif = /^STATION:/;
-
 
335
	if (motif.test(id)) {
-
 
336
		station = true;
-
 
337
	}
-
 
338
	return station;
138
}
339
}
139
 
340
 
140
function deplacerCartePointClique() {
341
function deplacerCarteSurPointClique() {
Line 141... Line 342...
141
	map.panTo(pointClique.position);
342
	map.panTo(pointClique.position);
142
}
343
}
143
 
344
 
144
function executerMarkerClusterer(points, bounds) {
345
function executerMarkerClusterer(points, bounds) {
145
	if (markerClusterer) {
346
	if (markerClusterer) {
146
		markerClusterer.clearMarkers();
347
		markerClusterer.clearMarkers();
147
	}
348
	}
Line 148... Line 349...
148
	markerClusterer = new MarkerClusterer(map, points);
349
	markerClusterer = new MarkerClusterer(map, points, {gridSize: 50, maxZoom: 18});
149
	map.fitBounds(bounds);
350
	map.fitBounds(bounds);
Line 150... Line 351...
150
}
351
}
151
 
352
 
152
/*+--------------------------------------------------------------------------------------------------------+*/
353
/*+--------------------------------------------------------------------------------------------------------+*/
-
 
354
// INFO BULLE
-
 
355
 
-
 
356
function initialiserInfoBulle() {
-
 
357
	google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle);
-
 
358
	google.maps.event.addListener(infoBulle, 'closeclick', surFermetureInfoBulle);
-
 
359
	google.maps.event.addListener(infoBulle, 'content_changed', definirLargeurInfoBulle);
-
 
360
}
-
 
361
 
-
 
362
function surFermetureInfoBulle() {
-
 
363
	//deplacerCarteSurPointClique();
-
 
364
}
-
 
365
 
-
 
366
function centrerInfoBulle() {
153
// INFO BULLE
367
	var limites = map.getBounds();
Line 154... Line 368...
154
 
368
	var centre = limites.getCenter();
155
function initialiserInfoBulle() {
369
	var nordEst = limites.getNorthEast();
-
 
370
	var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
-
 
371
	map.panTo(centreSudLatLng);
156
	google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle);
372
}
157
	google.maps.event.addListener(infoBulle, 'closeclick', deplacerCartePointClique);
373
 
Line -... Line 374...
-
 
374
function afficherInfoBulle() {
-
 
375
	var obsHtml = $("#tpl-obs").html();
-
 
376
	var largeur = definirLargeurInfoBulle();
-
 
377
	obsHtml = obsHtml.replace(/\{largeur\}/, largeur);
-
 
378
	infoBulle.setContent(obsHtml);
-
 
379
}
-
 
380
 
-
 
381
function definirLargeurInfoBulle() {
-
 
382
	var largeurViewPort = $(window).width();
-
 
383
	var lageurInfoBulle = null;
-
 
384
	if (largeurViewPort < 800) {
-
 
385
		largeurInfoBulle = 400;
-
 
386
	} else if (largeurViewPort >= 800 && largeurViewPort < 1200) {
158
}
387
		largeurInfoBulle = 500;
159
 
388
	} else if (largeurViewPort >= 1200) {
160
function afficherInfoBulle() {
389
		largeurInfoBulle = 600;
161
	var obsHtml = $("#tpl-obs").html();
390
	}
162
	infoBulle.setContent(obsHtml);
391
	return largeurInfoBulle;
Line 178... Line 407...
178
		if (depart == 0) {
407
		if (depart == 0) {
179
			obsStation = new Array();
408
			obsStation = new Array();
180
		}
409
		}
181
		//console.log("Chargement de "+depart+" à "+(depart+limite));
410
		//console.log("Chargement de "+depart+" à "+(depart+limite));
182
		var urlObs = observationsUrl+'&start={start}&limit='+limite;
411
		var urlObs = observationsUrl+'&start={start}&limit='+limite;
183
		urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationId);
412
		urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationInfos.id);
184
		urlObs = urlObs.replace(/\{nt\}/g, nt);
413
		urlObs = urlObs.replace(/\{nt\}/g, nt);
185
		urlObs = urlObs.replace(/\{start\}/g, depart);
414
		urlObs = urlObs.replace(/\{start\}/g, depart);
Line 186... Line 415...
186
		
415
		
187
		$.getJSON(urlObs, function(observations){
416
		$.getJSON(urlObs, function(observations){
188
			obsStation = obsStation.concat(observations.observations);
-
 
189
			if (depart == 0) {
-
 
190
				actualiserInfosStation(observations);
-
 
191
				actualiserPagineur();
-
 
192
				creerTitreInfoBulle();
-
 
193
			}
-
 
194
			//console.log("Chargement ok");
417
			obsStation = obsStation.concat(observations.observations);
195
			chargerObs(depart+limite, station.obsNbre);
418
			chargerObs(depart+limite, pointClique.stationInfos.nbre);
196
		});
419
		});
197
	} else {
420
	} else {
198
		if (pagineur.limite < total) {
421
		if (pagineur.limite < total) {
-
 
422
			afficherPagination();
199
			afficherPagination();
423
			surClicPagePagination(0, null);
200
		} else {
424
		} else {
201
			surClicPagePagination(0, null);
425
			surClicPagePagination(0, null);
202
			selectionnerOnglet("#obs-vue-"+pagineur.format);
426
			selectionnerOnglet("#obs-vue-"+pagineur.format);
203
		}
427
		}
204
	}
428
	}
Line 205... Line -...
205
}
-
 
206
 
-
 
207
function actualiserInfosStation(infos) {
-
 
208
	station.commune = infos.commune;
-
 
209
	station.obsNbre = infos.total;
-
 
210
}
429
}
211
 
430
 
212
function actualiserPagineur() {
431
function actualiserPagineur() {
213
	pagineur.stationId = pointClique.stationId;
-
 
214
	pagineur.total = station.obsNbre;
432
	pagineur.stationId = pointClique.stationInfos.id;
215
	//console.log("Total pagineur: "+pagineur.total);
433
	pagineur.total = pointClique.stationInfos.nbre;
216
	if (pagineur.total > 4) {
434
	if (pagineur.total > 4) {
217
		pagineur.format = 'tableau';
435
		pagineur.format = 'tableau';
218
	} else {
436
	} else {
Line 258... Line 476...
258
	if (pagineur.format == 'liste') {
476
	if (pagineur.format == 'liste') {
259
		ajouterGaleriePhoto("a.cel-img");
477
		ajouterGaleriePhoto("a.cel-img");
260
	}
478
	}
261
}
479
}
Line 262... Line 480...
262
 
480
 
-
 
481
function afficherTitreInfoBulle() {
-
 
482
	var titre = '';
-
 
483
	titre += pointClique.stationInfos.nbre+' observation';
-
 
484
	titre += (pointClique.stationInfos.nbre > 1) ? 's': '' ;
-
 
485
	titre += ' pour ';
-
 
486
	if (etreMarqueurCommune(pointClique.stationInfos.id)) {
-
 
487
		nomStation = 'la commune : ';
-
 
488
	} else {
-
 
489
		nomStation = 'la station : ';
263
function creerTitreInfoBulle() {
490
	}
264
	$("#obs-total").text(station.obsNbre);
491
	titre += pointClique.stationInfos.nom;
265
	$("#obs-commune").text(station.commune);	
492
	$("#obs-station-titre").text(titre);	
Line 266... Line 493...
266
}
493
}
267
 
494
 
268
function initialiserContenuInfoBulle() {
495
function initialiserContenuInfoBulle() {
-
 
496
	afficherTitreInfoBulle();
-
 
497
	afficherMessageChargement('#observations');
269
	afficherOnglets();
498
	cacherContenuOnglets();
270
	afficherMessageChargement('#observations');
499
	afficherOnglets();
271
	ajouterTableauTriable("#obs-tableau");
500
	ajouterTableauTriable("#obs-tableau");
272
	afficherTextStationId();
501
	afficherTextStationId();
Line -... Line 502...
-
 
502
	corrigerLargeurInfoWindow();
-
 
503
}
-
 
504
 
-
 
505
function cacherContenuOnglets() {
-
 
506
	$("#obs-vue-tableau").css("display", "none");
273
	corrigerLargeurInfoWindow();
507
	$("#obs-vue-liste").css("display", "none");
274
}
508
}
275
 
509
 
276
function afficherOnglets() {
510
function afficherOnglets() {
277
	var $tabs = $('#obs').tabs();
511
	var $tabs = $('#obs').tabs();
278
	$('#obs').bind('tabsselect', function(event, ui) {
512
	$('#obs').bind('tabsselect', function(event, ui) {
279
		if (ui.panel.id == 'obs-vue-tableau') {
513
		if (ui.panel.id == 'obs-vue-tableau') {
280
			surClicAffichageTableau();
514
			surClicAffichageTableau();
281
		} else if (ui.panel.id == 'obs-vue-liste') {
515
		} else if (ui.panel.id == 'obs-vue-liste') {
-
 
516
			surClicAffichageListe();
282
			surClicAffichageListe();
517
		}
-
 
518
	});
-
 
519
	if (pointClique.stationInfos.nbre > 4) {
-
 
520
		$tabs.tabs('select', "#obs-vue-tableau");
-
 
521
	} else {
283
		}
522
		$tabs.tabs('select', "#obs-vue-liste");
Line 284... Line 523...
284
	});
523
	}
-
 
524
	
285
	$tabs.tabs('select', "#obs-vue-"+pagineur.format);
525
}
286
}
526
 
Line 287... Line 527...
287
 
527
function selectionnerOnglet(onglet) {
288
function selectionnerOnglet(onglet) {
528
	$(onglet).css('display', 'block');
289
	$('#obs').tabs('select', onglet);
529
	$('#obs').tabs('select', onglet);
Line 290... Line 530...
290
}
530
}
291
 
531
 
292
function afficherTextStationId() {
532
function afficherTextStationId() {
Line 293... Line 533...
293
	$('#obs-station-id').text(pointClique.stationId);
533
	$('#obs-station-id').text(pointClique.stationInfos.id);
294
}
-
 
295
 
534
}
296
function corrigerLargeurInfoWindow() {
535
 
297
	$("#info-bulle").width($("#info-bulle").width() - 17);
536
function corrigerLargeurInfoWindow() {
298
}
537
	$("#info-bulle").width($("#info-bulle").width() - 17);
Line 299... Line 538...
299
 
538
}
300
function surClicAffichageTableau(event) {
-
 
301
	//console.log('tableau');
539
 
302
	pagineur.format = 'tableau';
540
function surClicAffichageTableau(event) {
303
	mettreAJourObservations();
541
	pagineur.format = 'tableau';
304
	mettreAJourTableauTriable("#obs-tableau");
542
	mettreAJourObservations();
Line 409... Line 647...
409
		}
647
		}
410
	});
648
	});
411
}
649
}
Line 412... Line 650...
412
 
650
 
413
function chargerInfoObsPourMessage(idObs) {
651
function chargerInfoObsPourMessage(idObs) {
414
	var nomSci = trim($(".cel-obs-"+idObs+" .nom-sci:eq(0)").text());
652
	var nomSci = jQuery.trim($(".cel-obs-"+idObs+" .nom-sci:eq(0)").text());
415
	var date = trim($(".cel-obs-"+idObs+" .date:eq(0)").text());
653
	var date = jQuery.trim($(".cel-obs-"+idObs+" .date:eq(0)").text());
416
	var lieu = trim($(".cel-obs-"+idObs+" .lieu:eq(0)").text());
654
	var lieu = jQuery.trim($(".cel-obs-"+idObs+" .lieu:eq(0)").text());
417
	var sujet = "Observation #"+idObs+" de "+nomSci;
655
	var sujet = "Observation #"+idObs+" de "+nomSci;
418
	var message = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de \""+nomSci+'" du "'+date+'" au lieu "'+lieu+'".';
656
	var message = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de \""+nomSci+'" du "'+date+'" au lieu "'+lieu+'".';
419
	$("#fc_sujet").attr('value', sujet);
657
	$("#fc_sujet").attr('value', sujet);
420
	$("#fc_message").text(message);
658
	$("#fc_message").text(message);
Line 447... Line 685...
447
		var donnees = new Array();
685
		var donnees = new Array();
448
		$.each($(this).serializeArray(), function (index, champ) {
686
		$.each($(this).serializeArray(), function (index, champ) {
449
			var cle = champ.name;
687
			var cle = champ.name;
450
			cle = cle.replace(/^fc_/, '');
688
			cle = cle.replace(/^fc_/, '');
Line 451... Line 689...
451
			
689
			
452
			if (cle = 'sujet') {
690
			if (cle == 'sujet') {
453
				champ.value += " - Carnet en ligne - Tela Botanica";
691
				champ.value += " - Carnet en ligne - Tela Botanica";
454
			}
692
			}
455
			if (cle == 'message') {
693
			if (cle == 'message') {
456
				champ.value += "\n--\n"+
694
				champ.value += "\n--\n"+
457
					"Ce message vous est envoyé par l'intermédiaire du widget Cartographique "+
695
					"Ce message vous est envoyé par l'intermédiaire du widget carto "+
458
					"du Carnet en Ligne du réseau Tela Botanica.\n"+
696
					"du Carnet en Ligne du réseau Tela Botanica.\n"+
459
					"http://www.tela-botanica.org/widget:cel:carto";
697
					"http://www.tela-botanica.org/widget:cel:carto";
Line 460... Line 698...
460
			}
698
			}
Line 494... Line 732...
494
				if (erreurMsg != '') {
732
				if (erreurMsg != '') {
495
					$("#fc-zone-dialogue").append('<p class="msg">'+
733
					$("#fc-zone-dialogue").append('<p class="msg">'+
496
							'Une erreur est survenue lors de la transmission de votre message.'+'<br />'+
734
							'Une erreur est survenue lors de la transmission de votre message.'+'<br />'+
497
							'Vous pouvez signaler le disfonctionnement à <a href="'+
735
							'Vous pouvez signaler le disfonctionnement à <a href="'+
498
							'mailto:cel@tela-botanica.org'+'?'+
736
							'mailto:cel@tela-botanica.org'+'?'+
499
							'subject=Disfonctionnement du widget de Cartographie'+
737
							'subject=Disfonctionnement du widget carto'+
500
							"&body="+erreurMsg+"\nDébogage :\n"+debugMsg+
738
							"&body="+erreurMsg+"\nDébogage :\n"+debugMsg+
501
							'">cel@tela-botanica.org</a>.'+
739
							'">cel@tela-botanica.org</a>.'+
502
							'</p>');
740
							'</p>');
503
				}
741
				}
504
				if (DEBUG) {
742
				if (DEBUG) {
Line 536... Line 774...
536
			chargerTaxons(depart+limite, infos.total);
774
			chargerTaxons(depart+limite, infos.total);
537
		});
775
		});
538
	} else {
776
	} else {
539
		if (nt == '*') {
777
		if (nt == '*') {
540
			afficherTaxons();
778
			afficherTaxons();
541
		} else {
-
 
542
			afficherNomPlante();
-
 
543
		}
779
		}
-
 
780
		afficherTitreCarte();
544
	}
781
	}
545
}
782
}
Line 546... Line 783...
546
 
783
 
547
function afficherTaxons() {
-
 
548
	// Ajout du nombre de plantes au titre
784
function afficherTaxons() {
549
	$('.plantes-nbre').text(taxonsCarte.length.formaterNombre());
-
 
550
	
785
	$(".plantes-nbre").text(taxonsCarte.length);
551
	$("#tpl-taxons-liste").tmpl({'taxons':taxonsCarte}).appendTo("#pl-corps");
786
	$("#tpl-taxons-liste").tmpl({'taxons':taxonsCarte}).appendTo("#pl-corps");
552
	$('.taxon').live('click', filtrerParTaxon);
787
	$('.taxon').live('click', filtrerParTaxon);
Line 553... Line -...
553
}
-
 
554
 
-
 
555
function afficherNomPlante() {
-
 
556
	if (nt != '*') {
-
 
557
		var taxon = taxonsCarte[0];
-
 
558
		$('.plante-titre').text('pour '+taxon.nom);
-
 
Line 559... Line 788...
559
	}
788
}
560
}
789
 
561
 
790
 
562
function afficherPanneauLateral() {
791
function afficherPanneauLateral() {
Line 577... Line 806...
577
	$('#carte').css('left', '24px');
806
	$('#carte').css('left', '24px');
Line 578... Line 807...
578
	
807
	
579
	google.maps.event.trigger(map, 'resize');
808
	google.maps.event.trigger(map, 'resize');
Line 580... Line -...
580
};
-
 
581
 
-
 
582
function ouvrirPopUp(url, nom) {
-
 
583
	window.open(url, nom, 'scrollbars=yes,width=650,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no');
-
 
584
};
809
};
585
 
810
 
586
function filtrerParTaxon() {
811
function filtrerParTaxon() {
587
	var ntAFiltrer = $('.nt', this).text();
812
	var ntAFiltrer = $('.nt', this).text();
588
	infoBulle.close();
813
	infoBulle.close();
589
	$('#taxon-'+nt).removeClass('taxon-actif');
814
	$('#taxon-'+nt).removeClass('taxon-actif');
590
	if (nt == ntAFiltrer) {
815
	if (nt == ntAFiltrer) {
591
		nt = '*';
816
		nt = '*';
592
		executerMarkerClusterer(pointsOrigine, boundsOrigine);
817
		executerMarkerClusterer(pointsOrigine, boundsOrigine);
593
	} else {
-
 
594
		var url = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer)+
-
 
595
			'&formatRetour=jsonP'+
818
	} else {
596
			'&callback=?';
819
		var url = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer);
597
		$.getJSON(url, function (stationsFiltrees) {
820
		$.getJSON(url, function (stationsFiltrees) {
598
			stations = stationsFiltrees;
821
			stations = stationsFiltrees;
599
			nt = ntAFiltrer;
822
			nt = ntAFiltrer;
Line 604... Line 827...
604
};
827
};
Line 605... Line 828...
605
 
828
 
606
/*+--------------------------------------------------------------------------------------------------------+*/
829
/*+--------------------------------------------------------------------------------------------------------+*/
Line -... Line 830...
-
 
830
// FONCTIONS UTILITAIRES
-
 
831
 
-
 
832
function ouvrirPopUp(element, nomPopUp, event) {
-
 
833
	var options = 
-
 
834
		'width=650,'+
-
 
835
		'height=600,'+
-
 
836
		'scrollbars=yes,'+
-
 
837
		'directories=no,'+
-
 
838
		'location=no,'+
-
 
839
		'menubar=no,'+
-
 
840
		'status=no,'+
-
 
841
		'toolbar=no';
-
 
842
	var popUp = window.open(element.href, nomPopUp, options);
-
 
843
	if (window.focus) {
-
 
844
		popUp.focus();
-
 
845
	}
-
 
846
	return arreter(event);
-
 
847
};
-
 
848
 
-
 
849
function ouvrirNouvelleFenetre(element, event) {
-
 
850
	window.open(element.href);
-
 
851
	return arreter(event);
607
// FONCTIONS UTILITAIRES
852
}
608
 
853
 
609
function arreter(event) {
854
function arreter(event) {
610
	if (event.stopPropagation) {
855
	if (event.stopPropagation) {
611
		event.stopPropagation();
856
		event.stopPropagation();
612
	} else if (window.event) {
857
	} else if (window.event) {
-
 
858
		window.event.cancelBubble = true;
-
 
859
	}
-
 
860
	if (event.preventDefault) {
-
 
861
		event.preventDefault();
613
		window.event.cancelBubble = true;
862
	}
614
	}
863
	event.returnValue = false;
Line 615... Line 864...
615
	return false;
864
	return false;
616
}
865
}
Line 698... Line 947...
698
		});
947
		});
699
	} else {
948
	} else {
700
		msg = "La variable vaut null.";
949
		msg = "La variable vaut null.";
701
	}
950
	}
702
	console.log(msg);
951
	console.log(msg);
703
}
-
 
704
 
-
 
705
function trim (chaine) {
-
 
706
	return chaine.replace(/^\s+/g, '').replace(/\s+$/g, '');
-
 
707
}
952
}
708
953