Subversion Repositories eFlore/Applications.cel

Rev

Rev 1044 | Rev 2286 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1044 Rev 1799
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
/**
-
 
6
 * Indication de certaines variables ajoutée par php
5
var pointImageUrl = 'http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png';
7
* var communeImageUrl ;
-
 
8
* var pointImageUrl ;
-
 
9
* var groupeImageUrlTpl ;
-
 
10
*/
-
 
11
var pointsOrigine = null;
6
var pointsOrigine = null;
12
var boundsOrigine = null;
7
var boundsOrigine = null;
13
var markerClusterer = null;
8
var markerClusterer = null;
14
var map = null;
9
var map = null;
15
var infoBulle = new google.maps.InfoWindow();
10
var infoBulle = new google.maps.InfoWindow();
16
var stations = null;
-
 
17
var pointClique = null;
11
var pointClique = null;
18
var carteCentre = new google.maps.LatLng(25, 10);
12
var carteCentre = new google.maps.LatLng(46.4, 3.10);
19
var carteOptions = {
13
var carteOptions = {
20
	zoom: 3,
14
	zoom: 6,
21
	center:carteCentre,
-
 
22
	mapTypeId: google.maps.MapTypeId.ROADMAP,
15
	mapTypeId: google.maps.MapTypeId.ROADMAP,
23
	mapTypeControlOptions: {
16
	mapTypeControlOptions: {
24
		mapTypeIds: ['OSM', 
17
		mapTypeIds: ['OSM', 
25
		             google.maps.MapTypeId.ROADMAP, 
18
		             google.maps.MapTypeId.ROADMAP, 
26
		             google.maps.MapTypeId.HYBRID, 
19
		             google.maps.MapTypeId.HYBRID, 
27
		             google.maps.MapTypeId.SATELLITE, 
20
		             google.maps.MapTypeId.SATELLITE, 
28
		             google.maps.MapTypeId.TERRAIN]
21
		             google.maps.MapTypeId.TERRAIN]
29
	}
22
	}
30
};			
23
};			
-
 
24
var ctaLayer = null;
31
var osmMapType = new google.maps.ImageMapType({
25
var osmMapType = new google.maps.ImageMapType({
32
	getTileUrl: function(coord, zoom) {
26
	getTileUrl: function(coord, zoom) {
33
		return "http://tile.openstreetmap.org/" +
27
		return "http://tile.openstreetmap.org/" +
34
		zoom + "/" + coord.x + "/" + coord.y + ".png";
28
		zoom + "/" + coord.x + "/" + coord.y + ".png";
35
	},
29
	},
Line 37... Line 31...
37
	isPng: true,
31
	isPng: true,
38
	alt: "OpenStreetMap",
32
	alt: "OpenStreetMap",
39
	name: "OSM",
33
	name: "OSM",
40
	maxZoom: 19
34
	maxZoom: 19
41
});
35
});
42
var ctaLayer = null;
-
 
43
var pagineur = {'limite':50, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
36
var pagineur = {'limite':50, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
44
var station = {'commune':'', 'obsNbre':0};
37
var station = {'commune':'', 'obsNbre':0};
45
var obsStation = new Array();
38
var obsStation = new Array();
46
var obsPage = new Array();
39
var obsPage = new Array();
47
var taxonsCarte = new Array();
40
var taxonsCarte = new Array();
48
var mgr = null;
-
 
49
var marqueursCache = new Array();
-
 
50
var zonesCache = new Array();
-
 
51
var requeteChargementPoints;
-
 
52
/*+--------------------------------------------------------------------------------------------------------+*/
41
/*+--------------------------------------------------------------------------------------------------------+*/
53
// INITIALISATION DU CODE
42
// INITIALISATION DU CODE
Line 54... Line 43...
54
 
43
 
55
//Déclenchement d'actions quand JQuery et le document HTML sont OK
44
//Déclenchement d'actions quand JQuery et le document HTML sont OK
56
$(document).ready(function() {
45
$(document).ready(function() {
57
	initialiserWidget();
46
	initialiserWidget();
Line 58... Line 47...
58
});
47
});
-
 
48
 
59
 
49
function initialiserWidget() {
60
function initialiserWidget() {
50
	afficherStats();
61
	definirTailleTitre();
51
	definirTailleTitre();
-
 
52
	initialiserAffichageCarte();
62
	initialiserAffichageCarte();
53
	initialiserAffichagePanneauLateral();
63
	initialiserAffichagePanneauLateral();
-
 
64
	initialiserCarte();
54
	
65
	initialiserGestionnaireMarqueurs()
55
	initialiserCarte();
66
	initialiserInfoBulle();
56
	initialiserInfoBulle();
67
	initialiserFormulaireContact();
57
	initialiserFormulaireContact();
68
	chargerLimitesCommunales();
-
 
69
	attribuerListenerCarte();
58
	chargerLimitesCommunales();
Line 70... Line 59...
70
	programmerRafraichissementCarte();
59
	rafraichirCarte();
71
}
60
}
Line 72... Line 61...
72
 
61
 
73
/*+--------------------------------------------------------------------------------------------------------+*/
-
 
74
// AFFICHAGE GÉNÉRAL
-
 
75
 
62
/*+--------------------------------------------------------------------------------------------------------+*/
76
function afficherTitreCarte() {
-
 
77
	if (stations != null && taxonsCarte.length > 0) {
-
 
78
		var obsNbre = stations.stats.observations;
-
 
79
		var obsNbreFormate = stations.stats.observations.formaterNombre();
63
// AFFICHAGE GÉNÉRAL
80
		var plteNbre = taxonsCarte.length;
-
 
81
		var plteNbreFormate = taxonsCarte.length.formaterNombre();
64
 
82
		var communeNbre = stations.stats.communes;
-
 
83
		var communeNbreFormate = stations.stats.communes.formaterNombre();
-
 
84
	
-
 
85
		var titre = obsNbreFormate+' observation';
-
 
86
		titre += (obsNbre > 1) ? 's' : '' ;
-
 
87
		
-
 
88
		if (nt == '*') {
-
 
89
			titre += ' de '+plteNbreFormate+' plante';
-
 
90
			titre += (plteNbre > 1) ? 's' : '' ;
-
 
91
		} else {
-
 
92
			if (taxonsCarte[0]) {
-
 
93
				var taxon = taxonsCarte[0];
-
 
94
				titre += ' pour '+taxon.nom;
-
 
95
			}
-
 
96
		}
-
 
97
		
65
function afficherStats() {
98
		titre += ' sur '+communeNbreFormate+' commune';
-
 
99
		titre += (communeNbre > 1) ? 's' : '' ;
66
	// Ajout du nombre de communes où des observations ont eu lieu
Line 100... Line 67...
100
		
67
	$('#commune-nbre').text(stations.stats.communes.formaterNombre());
101
		$('#carte-titre-infos').text(titre);
68
	// Ajout du nombre d'observations
102
	}
69
	$('#obs-nbre').text(stations.stats.observations.formaterNombre());
Line 131... Line 98...
131
	map = new google.maps.Map(document.getElementById('carte'), carteOptions);
98
	map = new google.maps.Map(document.getElementById('carte'), carteOptions);
132
	// Ajout de la couche OSM à la carte
99
	// Ajout de la couche OSM à la carte
133
	map.mapTypes.set('OSM', osmMapType);
100
	map.mapTypes.set('OSM', osmMapType);
134
}
101
}
Line 135... Line -...
135
 
-
 
136
function initialiserGestionnaireMarqueurs() {
-
 
137
	mgr = new MarkerManager(map);
-
 
Line 138... Line 102...
138
}
102
 
139
 
103
 
140
function chargerLimitesCommunales() {
104
function chargerLimitesCommunales() {
141
	if (urlsLimitesCommunales != null) {
105
	if (urlsLimitesCommunales != null) {
142
		for (urlId in urlsLimitesCommunales) { 
106
		for (urlId in urlsLimitesCommunales) { 
143
			var url = urlsLimitesCommunales[urlId];
107
			var url = urlsLimitesCommunales[urlId];
144
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: false});
108
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true});
145
			ctaLayer.setMap(map);
109
			ctaLayer.setMap(map);
146
		}
110
		}
Line 147... Line -...
147
	}
-
 
148
}
-
 
149
 
-
 
150
var listener = null;
-
 
151
var timer = null;
-
 
152
function attribuerListenerCarte() {
-
 
153
	listener = google.maps.event.addListener(map, 'bounds_changed', function(){
-
 
154
		programmerRafraichissementCarte();
-
 
155
	});
-
 
156
	listener = google.maps.event.addListener(map, 'zoom_changed', function(){
-
 
157
		programmerRafraichissementCarte();
-
 
158
	});
-
 
159
}
-
 
160
function programmerRafraichissementCarte() {
-
 
161
	if(timer != null) {
-
 
162
        window.clearTimeout(timer);
-
 
163
    }
-
 
164
	if(requeteChargementPoints != null) {
-
 
165
		requeteChargementPoints.abort();
-
 
166
	}
-
 
167
	timer = window.setTimeout(function() {
-
 
168
		var zoom = map.getZoom();
-
 
169
		var NELatLng = (map.getBounds().getNorthEast().lat())+'|'+(map.getBounds().getNorthEast().lng());
-
 
170
		var SWLatLng = (map.getBounds().getSouthWest().lat())+'|'+(map.getBounds().getSouthWest().lng());
-
 
171
		chargerMarqueurs(zoom, NELatLng, SWLatLng);
-
 
172
    }, 400);		
-
 
173
}
-
 
174
 
-
 
175
var marqueurs = new Array();
-
 
176
function chargerMarqueurs(zoom, NELatLng, SWLatLng) {
-
 
177
	var url = stationsUrl+
-
 
178
		'&zoom='+zoom+
-
 
179
		'&ne='+NELatLng+
-
 
180
		'&sw='+SWLatLng;
-
 
181
	
-
 
182
	if(infoBulleOuverte) {
-
 
183
		return;
-
 
184
	}
-
 
185
	
-
 
186
	if(requeteChargementPoints != null) {
-
 
187
		requeteChargementPoints.abort();
-
 
188
		cacherMessageChargementPoints();
-
 
189
	}
-
 
190
	
-
 
191
	afficherMessageChargementPoints();
-
 
192
	requeteChargementPoints = $.getJSON(url, function(data) {
-
 
193
		rafraichirMarqueurs(data);
-
 
194
		cacherMessageChargementPoints();
-
 
195
	});
-
 
196
}
-
 
197
 
-
 
198
function afficherMessageChargementPoints() {
-
 
199
	$('#zone-chargement-point').css('display','block');
-
 
200
}
-
 
201
 
-
 
202
function cacherMessageChargementPoints() {
-
 
203
	$('#zone-chargement-point').css('display','none');
111
	}
204
}
-
 
205
 
-
 
206
function rafraichirMarqueurs(data) {
-
 
207
	$.each(marqueurs, function(index, marqueur) {
-
 
208
		marqueur.setMap(null);
-
 
209
	});
-
 
210
	marqueurs = new Array();
-
 
211
	
-
 
212
	stations = data;
-
 
213
	afficherTitreCarte();
-
 
214
	
-
 
215
	$.each(stations.points, function (index, station) {		
-
 
216
		if(station != null) {
-
 
217
			var nouveauMarqueur = creerMarqueur(station);
-
 
218
			marqueurs.push(nouveauMarqueur);
-
 
219
		}
-
 
220
	});
-
 
221
}
-
 
222
 
-
 
223
function creerMarqueur(station) {
-
 
224
	var titre = '';
-
 
225
	if(station.nbreMarqueur) {
-
 
226
		titre = station.nbreMarqueur+' points renseignés';
-
 
227
	} else {
-
 
228
		if(station.nom) {
-
 
229
			titre = station.nom;
-
 
230
		}
-
 
231
	}
-
 
232
	//var titre = station['nbreMarqueur'];
-
 
233
	var icone = attribuerImageMarqueur(station['id'], station['nbreMarqueur']);
-
 
234
	var latLng = new google.maps.LatLng(station['lat'], station['lng']);
-
 
235
	var marqueur = new google.maps.Marker({
-
 
236
		position: latLng,
-
 
237
		icon: icone,
-
 
238
		title: ''+titre,
-
 
239
		map: map,
-
 
240
		stationInfos: station
-
 
241
	});
-
 
242
	attribuerListenerClick(marqueur, station['id']);
-
 
243
	marqueur.setMap(map);
-
 
244
    return marqueur;
-
 
245
}
-
 
246
 
-
 
247
function rendrePointsVisibles(bounds) {
-
 
248
	map.setCenter(bounds.getCenter());
-
 
249
	map.fitBounds(bounds);
-
 
250
	map.panToBounds(bounds);
-
 
251
}
-
 
252
 
112
}
253
function programmerRafraichissementCarteSauv() {
113
 
254
	
114
function rafraichirCarte() {
255
	var points = [];
-
 
256
	var bounds = new google.maps.LatLngBounds();
115
	var points = [];
257
	for (var i = 0; i < stations.points.length; ++i) {
116
	var bounds = new google.maps.LatLngBounds();
258
		var point = stations.points[i];
117
	for (var i = 0; i < stations.stats.communes; ++i) {
259
		var maLatLng = new google.maps.LatLng(point.lat, point.lng);
118
		var maLatLng = new google.maps.LatLng(stations.points[i].latitude, stations.points[i].longitude);
260
		var stationImage = attribuerImageMarqueur(point.id); 
119
		var pointImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(24, 32));
261
		var point = new google.maps.Marker({
120
		var point = new google.maps.Marker({
262
			position: maLatLng,
121
			position: maLatLng,
263
			map: map,
122
			map: map,
264
			icon: stationImage,
-
 
265
			stationInfos: point
-
 
266
		});
-
 
267
		bounds.extend(maLatLng);
-
 
Line 268... Line -...
268
		google.maps.event.addListener(point, 'click', surClickMarqueur);
-
 
269
		points.push(point);
-
 
270
	}
123
			icon: pointImage,
271
 
-
 
272
	if (pointsOrigine == null && boundsOrigine == null) {
-
 
273
		pointsOrigine = points;
-
 
274
		boundsOrigine = bounds;
-
 
275
	}
-
 
276
	
-
 
277
	executerMarkerClusterer(points, bounds);
-
 
278
}
-
 
279
 
-
 
280
function attribuerImageMarqueur(id, nbreMarqueur) {
-
 
281
	var marqueurImage = null;
-
 
282
	if (etreMarqueurCommune(id)) {
-
 
283
		marqueurImage = new google.maps.MarkerImage(communeImageUrl, new google.maps.Size(24, 32));
-
 
284
	} else if (etreMarqueurStation(id)) {
-
 
285
		marqueurImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(16, 16));
-
 
286
	} else if (etreMarqueurGroupe(id)) {
-
 
287
		var type = 0;
-
 
288
		var largeur = 0;
-
 
289
		var hauteur = 0;
-
 
290
		if (nbreMarqueur != null) {
-
 
291
			if (nbreMarqueur >= 2 && nbreMarqueur < 100 ) {
-
 
292
				type = '1';
-
 
293
				largeur = 53;
-
 
294
				hauteur = 52;
-
 
295
			} else if (nbreMarqueur >= 100 && nbreMarqueur < 1000 ) {
-
 
296
				type = '2';
-
 
297
				largeur = 56;
-
 
298
				hauteur = 55;
-
 
299
			} else if (nbreMarqueur >= 1000 && nbreMarqueur < 10000 ) {
-
 
300
				type = '3';
-
 
301
				largeur = 66;
-
 
302
				hauteur = 65;
-
 
303
			} else if (nbreMarqueur >= 10000 && nbreMarqueur < 20000 ) {
-
 
304
				type = '4';
-
 
305
				largeur = 78;
-
 
306
				hauteur = 77;
-
 
307
			} else if (nbreMarqueur >= 20000) {
-
 
308
				type = '5';
-
 
309
				largeur = 66;
-
 
310
				hauteur = 65;
-
 
311
			}
-
 
312
		}
-
 
313
		groupeImageUrl = groupeImageUrlTpl.replace(/\{type\}/, type);
-
 
314
		groupeImageUrl = groupeImageUrl.replace(/\{nbre\}/, nbreMarqueur);
-
 
315
		marqueurImage = new google.maps.MarkerImage(groupeImageUrl, new google.maps.Size(largeur, hauteur));
-
 
316
	}
-
 
317
	return marqueurImage
-
 
318
}
-
 
319
 
-
 
320
function attribuerListenerClick(marqueur, id) {
-
 
321
	if (etreMarqueurCommune(id) || etreMarqueurStation(id)) {
-
 
322
		google.maps.event.addListener(marqueur, 'click', surClickMarqueur);
-
 
323
	} else if (etreMarqueurGroupe(id)) {
-
 
324
		google.maps.event.addListener(marqueur, 'click', surClickGroupe);
-
 
325
	}
-
 
326
}
-
 
327
 
-
 
328
function surClickMarqueur(event) {
-
 
Line -... Line 124...
-
 
124
			stationId: stations.points[i].id
329
 
125
		});
330
	if(infoBulleOuverte) {
126
 
331
	    infoBulle.close();
-
 
Line 332... Line 127...
332
	}
127
		bounds.extend(maLatLng);
333
  
128
		
334
	pointClique = this;
129
		google.maps.event.addListener(point, 'click', function() {
335
	infoBulle.open(map, this);
130
			pointClique =  this;
336
	actualiserPagineur();
131
			infoBulle.open(map, this);
Line 337... Line 132...
337
	
132
			
338
	var limites = map.getBounds();
-
 
339
	var centre = limites.getCenter();
-
 
340
	var nordEst = limites.getNorthEast();
-
 
341
	var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
-
 
342
	map.panTo(centreSudLatLng);
-
 
343
	
-
 
344
	afficherInfoBulle();
133
			var limites = map.getBounds();
345
}
134
			var centre = limites.getCenter();
Line 346... Line -...
346
 
-
 
347
function surClickGroupe() {
-
 
348
	map.setCenter(this.getPosition());
-
 
349
	var nouveauZoom = map.getZoom() + 2;
135
			var nordEst = limites.getNorthEast();
350
	map.setZoom(nouveauZoom);
-
 
351
	mgr.clearMarkers();
-
 
352
}
-
 
353
 
136
			var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
Line 354... Line 137...
354
function etreMarqueurGroupe(id) {
137
			map.panTo(centreSudLatLng);
355
	var groupe = false;
138
			
356
	var motif = /^GROUPE/;
-
 
357
	if (motif.test(id)) {
-
 
358
		groupe = true;
139
			afficherInfoBulle();
359
	}
-
 
360
	return groupe;
-
 
361
}
140
			chargerObs(0, 0);
Line 362... Line 141...
362
 
141
		});
363
function etreMarqueurCommune(id) {
-
 
364
	var commune = false;
-
 
365
	var motif = /^COMMUNE:/;
-
 
366
	if (motif.test(id)) {
-
 
367
		commune = true;
-
 
368
	}
-
 
369
	return commune;
142
		
Line 370... Line 143...
370
}
143
		points.push(point);
371
 
144
	}
372
function etreMarqueurStation(id) {
145
 
Line 373... Line 146...
373
	var station = false;
146
	if (pointsOrigine == null && boundsOrigine == null) {
374
	var motif = /^STATION:/;
147
		pointsOrigine = points;
375
	if (motif.test(id)) {
148
		boundsOrigine = bounds;
376
		station = true;
149
	}
377
	}
150
	
378
	return station;
151
	executerMarkerClusterer(points, bounds);
379
}
152
}
Line 380... Line 153...
380
 
153
 
381
function deplacerCarteSurPointClique() {
154
function deplacerCartePointClique() {
382
	map.panTo(pointClique.position);
-
 
-
 
155
	map.panTo(pointClique.position);
383
}
156
}
384
 
157
 
385
function executerMarkerClusterer(points, bounds) {
158
function executerMarkerClusterer(points, bounds) {
386
	if (markerClusterer) {
-
 
387
		markerClusterer.clearMarkers();
-
 
388
	}
-
 
389
	markerClusterer = new MarkerClusterer(map, points, {gridSize: 50, maxZoom: 18});
-
 
390
	map.fitBounds(bounds);
-
 
391
}
-
 
392
 
-
 
393
/*+--------------------------------------------------------------------------------------------------------+*/
-
 
394
// INFO BULLE
-
 
395
var infoBulleOuverte = false;
-
 
396
function initialiserInfoBulle() {
-
 
397
	google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle);
-
 
398
	google.maps.event.addListener(infoBulle, 'closeclick', surFermetureInfoBulle);
-
 
399
	google.maps.event.addListener(infoBulle, 'content_changed', definirLargeurInfoBulle);
-
 
400
}
159
	if (markerClusterer) {
Line 401... Line 160...
401
 
160
		markerClusterer.clearMarkers();
402
function surFermetureInfoBulle() {
161
	}
403
	infoBulleOuverte = false;
162
	markerClusterer = new MarkerClusterer(map, points);
404
	programmerRafraichissementCarte();
163
	map.fitBounds(bounds);
405
}
164
}
406
 
-
 
407
function centrerInfoBulle() {
-
 
408
	var limites = map.getBounds();
165
 
Line 409... Line 166...
409
	var centre = limites.getCenter();
166
/*+--------------------------------------------------------------------------------------------------------+*/
410
	var nordEst = limites.getNorthEast();
167
// INFO BULLE
411
	var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
168
 
Line 438... Line 195...
438
	if ($('#chargement').get() == '') {
195
	if ($('#chargement').get() == '') {
439
		$('#tpl-chargement').tmpl().appendTo(element);
196
		$('#tpl-chargement').tmpl().appendTo(element);
440
	}
197
	}
441
}
198
}
Line 442... Line -...
442
 
-
 
443
function afficherMessageChargementTitreInfoBulle() {
-
 
444
	$("#obs-station-titre").text("Chargement des observations");	
-
 
445
}
-
 
446
 
199
 
447
function supprimerMessageChargement() {
200
function supprimerMessageChargement() {
448
	$('#chargement').remove();
201
	$('#chargement').remove();
Line 449... Line 202...
449
}
202
}
450
 
203
 
451
function chargerObs(depart, total) {
204
function chargerObs(depart, total) {
452
	if (depart == 0 || depart < total) {
205
	if (depart == 0 || depart < total) {
453
		var limite = 300;
206
		var limite = 300;
454
		if (depart == 0) {
207
		if (depart == 0) {
455
			viderTableauObs();
-
 
-
 
208
			obsStation = new Array();
456
		}
209
		}
457
		
210
		//console.log("Chargement de "+depart+" à "+(depart+limite));
458
		var urlObs = observationsUrl+'&start={start}&limit='+limite;
-
 
459
		urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationInfos.id);
-
 
460
		if (pointClique.stationInfos.type_emplacement == 'communes') {
-
 
461
			urlObs = urlObs.replace(/commune=%2A/g, 'commune='+pointClique.stationInfos.nom);
211
		var urlObs = observationsUrl+'&start={start}&limit='+limite;
462
		}
212
		urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationId);
Line 463... Line 213...
463
		urlObs = urlObs.replace(/\{nt\}/g, nt);
213
		urlObs = urlObs.replace(/\{nt\}/g, nt);
464
		urlObs = urlObs.replace(/\{start\}/g, depart);
-
 
465
		
-
 
466
		$.getJSON(urlObs, function(observations){
-
 
467
			surRetourChargementObs(observations, depart, total);
-
 
468
			chargerObs(depart+limite, observations.total);
-
 
469
		});
-
 
470
	}
-
 
471
}
-
 
472
 
-
 
473
function viderTableauObs() {
-
 
474
	obsStation = new Array();	
-
 
475
	surClicPagePagination(0, null);
-
 
476
}
214
		urlObs = urlObs.replace(/\{start\}/g, depart);
477
 
215
		
478
function surRetourChargementObs(observations, depart, total) {
216
		$.getJSON(urlObs, function(observations){
-
 
217
			obsStation = obsStation.concat(observations.observations);
479
	obsStation = obsStation.concat(observations.observations);
218
			if (depart == 0) {
480
	if (depart == 0) {
-
 
481
		actualiserInfosStation(observations);
219
				actualiserInfosStation(observations);
-
 
220
				actualiserPagineur();
-
 
221
				creerTitreInfoBulle();
482
		creerTitreInfoBulle();
222
			}
-
 
223
			//console.log("Chargement ok");
-
 
224
			chargerObs(depart+limite, station.obsNbre);
483
		surClicPagePagination(0, null);	
225
		});
-
 
226
	} else {
484
	}
227
		if (pagineur.limite < total) {
485
	
228
			afficherPagination();
486
	afficherPagination();
229
		} else {
487
	actualiserPagineur();
-
 
488
	selectionnerOnglet("#obs-vue-"+pagineur.format);
-
 
489
}
-
 
490
 
-
 
491
function actualiserInfosStation(infos) {
230
			surClicPagePagination(0, null);
492
	pointClique.stationInfos.commune = infos.commune;
-
 
493
	pointClique.stationInfos.obsNbre = infos.total;
-
 
494
}
-
 
495
 
-
 
496
function creerTitreInfoBulle() {
-
 
497
	$("#obs-total").text(station.obsNbre);
-
 
498
	$("#obs-commune").text(station.commune);
-
 
499
	var titre = '';
-
 
500
	titre += pointClique.stationInfos.obsNbre+' observation';
-
 
501
	titre += (pointClique.stationInfos.obsNbre > 1) ? 's': '' ;
-
 
502
	titre += ' pour ';
-
 
503
	if (etreMarqueurCommune(pointClique.stationInfos.id)) {
-
 
504
		nomStation = 'la commune : ';
231
			selectionnerOnglet("#obs-vue-"+pagineur.format);
-
 
232
		}
505
	} else {
233
	}
-
 
234
}
506
		nomStation = 'la station : ';
235
 
507
	}
236
function actualiserInfosStation(infos) {
Line 508... Line 237...
508
	titre += pointClique.stationInfos.nom;
237
	station.commune = infos.commune;
509
	$("#obs-station-titre").text(titre);	
238
	station.obsNbre = infos.total;
510
}
239
}
-
 
240
 
511
 
241
function actualiserPagineur() {
512
function actualiserPagineur() {
242
	pagineur.stationId = pointClique.stationId;
513
	pagineur.stationId = pointClique.stationInfos.id;
243
	pagineur.total = station.obsNbre;
514
	pagineur.total = pointClique.stationInfos.obsNbre;
244
	//console.log("Total pagineur: "+pagineur.total);
515
	if (pagineur.total > 4) {
245
	if (pagineur.total > 4) {
Line 557... Line 287...
557
	if (pagineur.format == 'liste') {
287
	if (pagineur.format == 'liste') {
558
		ajouterGaleriePhoto("a.cel-img");
288
		ajouterGaleriePhoto("a.cel-img");
559
	}
289
	}
560
}
290
}
Line -... Line 291...
-
 
291
 
-
 
292
function creerTitreInfoBulle() {
-
 
293
	$("#obs-total").text(station.obsNbre);
-
 
294
	$("#obs-commune").text(station.commune);	
-
 
295
}
561
 
296
 
562
function initialiserContenuInfoBulle() {
-
 
563
	afficherMessageChargement('#observations');
-
 
564
	cacherContenuOnglets();
297
function initialiserContenuInfoBulle() {
-
 
298
	afficherOnglets();
565
	afficherOnglets();
299
	afficherMessageChargement('#observations');
566
	ajouterTableauTriable("#obs-tableau");
300
	ajouterTableauTriable("#obs-tableau");
567
	afficherTextStationId();
301
	afficherTextStationId();
568
	corrigerLargeurInfoWindow();
302
	corrigerLargeurInfoWindow();
Line 569... Line -...
569
}
-
 
570
 
-
 
571
function cacherContenuOnglets() {
-
 
572
	$("#obs-vue-tableau").css("display", "none");
-
 
573
	$("#obs-vue-liste").css("display", "none");
-
 
574
}
303
}
575
 
304
 
576
function afficherOnglets() {
305
function afficherOnglets() {
577
	var $tabs = $('#obs').tabs();
306
	var $tabs = $('#obs').tabs();
578
	$('#obs').bind('tabsselect', function(event, ui) {
307
	$('#obs').bind('tabsselect', function(event, ui) {
579
		if (ui.panel.id == 'obs-vue-tableau') {
308
		if (ui.panel.id == 'obs-vue-tableau') {
580
			surClicAffichageTableau();
309
			surClicAffichageTableau();
581
		} else if (ui.panel.id == 'obs-vue-liste') {
310
		} else if (ui.panel.id == 'obs-vue-liste') {
582
			surClicAffichageListe();
311
			surClicAffichageListe();
583
		}
-
 
584
	});
312
		}
585
	if (pointClique.stationInfos.nbre > 4) {
-
 
586
		$tabs.tabs('select', "#obs-vue-tableau");
-
 
587
	} else {
-
 
588
		$tabs.tabs('select', "#obs-vue-liste");
-
 
589
	}
313
	});
Line 590... Line 314...
590
	
314
	$tabs.tabs('select', "#obs-vue-"+pagineur.format);
591
}
-
 
592
 
315
}
593
function selectionnerOnglet(onglet) {
316
 
Line 594... Line 317...
594
	$(onglet).css('display', 'block');
317
function selectionnerOnglet(onglet) {
595
	$('#obs').tabs('select', onglet);
318
	$('#obs').tabs('select', onglet);
596
}
319
}
Line 597... Line 320...
597
 
320
 
598
function afficherTextStationId() {
321
function afficherTextStationId() {
599
	$('#obs-station-id').text(pointClique.stationInfos.id);
322
	$('#obs-station-id').text(pointClique.stationId);
Line 600... Line 323...
600
}
323
}
-
 
324
 
601
 
325
function corrigerLargeurInfoWindow() {
602
function corrigerLargeurInfoWindow() {
326
	$("#info-bulle").width($("#info-bulle").width() - 17);
603
	$("#info-bulle").width($("#info-bulle").width() - 17);
327
}
604
}
328
 
Line 605... Line 329...
605
 
329
function surClicAffichageTableau(event) {
-
 
330
	//console.log('tableau');
606
function surClicAffichageTableau(event) {
331
	pagineur.format = 'tableau';
607
	pagineur.format = 'tableau';
332
	mettreAJourObservations();
608
	mettreAJourObservations();
333
	mettreAJourTableauTriable("#obs-tableau");
609
	mettreAJourTableauTriable("#obs-tableau");
334
}
Line 713... Line 438...
713
		}
438
		}
714
	});
439
	});
715
}
440
}
Line 716... Line 441...
716
 
441
 
717
function chargerInfoObsPourMessage(idObs) {
442
function chargerInfoObsPourMessage(idObs) {
718
	var nomSci = jQuery.trim($(".cel-obs-"+idObs+" .nom-sci:eq(0)").text());
443
	var nomSci = trim($(".cel-obs-"+idObs+" .nom-sci:eq(0)").text());
719
	var date = jQuery.trim($(".cel-obs-"+idObs+" .date:eq(0)").text());
444
	var date = trim($(".cel-obs-"+idObs+" .date:eq(0)").text());
720
	var lieu = jQuery.trim($(".cel-obs-"+idObs+" .lieu:eq(0)").text());
445
	var lieu = trim($(".cel-obs-"+idObs+" .lieu:eq(0)").text());
721
	var sujet = "Observation #"+idObs+" de "+nomSci;
446
	var sujet = "Observation #"+idObs+" de "+nomSci;
722
	var message = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de \""+nomSci+'" du "'+date+'" au lieu "'+lieu+'".';
447
	var message = "\n\n\n\n\n\n\n\n--\nConcerne l'observation de \""+nomSci+'" du "'+date+'" au lieu "'+lieu+'".';
723
	$("#fc_sujet").attr('value', sujet);
448
	$("#fc_sujet").attr('value', sujet);
724
	$("#fc_message").text(message);
449
	$("#fc_message").text(message);
Line 756... Line 481...
756
			if (cle == 'sujet') {
481
			if (cle == 'sujet') {
757
				champ.value += " - Carnet en ligne - Tela Botanica";
482
				champ.value += " - Carnet en ligne - Tela Botanica";
758
			}
483
			}
759
			if (cle == 'message') {
484
			if (cle == 'message') {
760
				champ.value += "\n--\n"+
485
				champ.value += "\n--\n"+
761
					"Ce message vous est envoyé par l'intermédiaire du widget carto "+
486
					"Ce message vous est envoyé par l'intermédiaire du widget Cartographique "+
762
					"du Carnet en Ligne du réseau Tela Botanica.\n"+
487
					"du Carnet en Ligne du réseau Tela Botanica.\n"+
763
					"http://www.tela-botanica.org/widget:cel:carto";
488
					"http://www.tela-botanica.org/widget:cel:carto";
764
			}
489
			}
Line 765... Line 490...
765
			
490
			
Line 798... Line 523...
798
				if (erreurMsg != '') {
523
				if (erreurMsg != '') {
799
					$("#fc-zone-dialogue").append('<p class="msg">'+
524
					$("#fc-zone-dialogue").append('<p class="msg">'+
800
							'Une erreur est survenue lors de la transmission de votre message.'+'<br />'+
525
							'Une erreur est survenue lors de la transmission de votre message.'+'<br />'+
801
							'Vous pouvez signaler le disfonctionnement à <a href="'+
526
							'Vous pouvez signaler le disfonctionnement à <a href="'+
802
							'mailto:cel@tela-botanica.org'+'?'+
527
							'mailto:cel@tela-botanica.org'+'?'+
803
							'subject=Disfonctionnement du widget carto'+
528
							'subject=Disfonctionnement du widget de Cartographie'+
804
							"&body="+erreurMsg+"\nDébogage :\n"+debugMsg+
529
							"&body="+erreurMsg+"\nDébogage :\n"+debugMsg+
805
							'">cel@tela-botanica.org</a>.'+
530
							'">cel@tela-botanica.org</a>.'+
806
							'</p>');
531
							'</p>');
807
				}
532
				}
808
				if (DEBUG) {
533
				if (DEBUG) {
Line 840... Line 565...
840
			chargerTaxons(depart+limite, infos.total);
565
			chargerTaxons(depart+limite, infos.total);
841
		});
566
		});
842
	} else {
567
	} else {
843
		if (nt == '*') {
568
		if (nt == '*') {
844
			afficherTaxons();
569
			afficherTaxons();
-
 
570
		} else {
-
 
571
			afficherNomPlante();
845
		}
572
		}
846
		afficherTitreCarte();
-
 
847
	}
573
	}
848
}
574
}
Line 849... Line 575...
849
 
575
 
-
 
576
function afficherTaxons() {
850
function afficherTaxons() {
577
	// Ajout du nombre de plantes au titre
-
 
578
	$('.plantes-nbre').text(taxonsCarte.length.formaterNombre());
851
	$(".plantes-nbre").text(taxonsCarte.length);
579
	
852
	$("#tpl-taxons-liste").tmpl({'taxons':taxonsCarte}).appendTo("#pl-corps");
580
	$("#tpl-taxons-liste").tmpl({'taxons':taxonsCarte}).appendTo("#pl-corps");
853
	$('.taxon').live('click', filtrerParTaxon);
581
	$('.taxon').live('click', filtrerParTaxon);
Line -... Line 582...
-
 
582
}
-
 
583
 
-
 
584
function afficherNomPlante() {
-
 
585
	if (nt != '*') {
-
 
586
		var taxon = taxonsCarte[0];
-
 
587
		$('.plante-titre').text('pour '+taxon.nom);
Line 854... Line 588...
854
}
588
	}
855
 
589
}
856
 
590
 
857
function afficherPanneauLateral() {
591
function afficherPanneauLateral() {
Line 872... Line 606...
872
	$('#carte').css('left', '24px');
606
	$('#carte').css('left', '24px');
Line 873... Line 607...
873
	
607
	
874
	google.maps.event.trigger(map, 'resize');
608
	google.maps.event.trigger(map, 'resize');
Line -... Line 609...
-
 
609
};
-
 
610
 
-
 
611
function ouvrirPopUp(url, nom) {
-
 
612
	window.open(url, nom, 'scrollbars=yes,width=650,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no');
875
};
613
};
876
 
614
 
877
function filtrerParTaxon() {
615
function filtrerParTaxon() {
878
	var ntAFiltrer = $('.nt', this).text();
-
 
879
	infoBulle.close();
-
 
880
	var zoom = map.getZoom();
-
 
881
	var NELatLng = map.getBounds().getNorthEast().lat()+'|'+map.getBounds().getNorthEast().lng();
-
 
882
	var SWLatLng = map.getBounds().getSouthWest().lat()+'|'+map.getBounds().getSouthWest().lng();
616
	var ntAFiltrer = $('.nt', this).text();
883
	
617
	infoBulle.close();
884
	$('#taxon-'+nt).removeClass('taxon-actif');
618
	$('#taxon-'+nt).removeClass('taxon-actif');
885
	if (nt == ntAFiltrer) {
-
 
886
		nt = '*';
619
	if (nt == ntAFiltrer) {
887
		stationsUrl = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+nt);
620
		nt = '*';
888
		chargerMarqueurs(zoom, NELatLng, SWLatLng);
621
		executerMarkerClusterer(pointsOrigine, boundsOrigine);
889
	} else {
-
 
890
		stationsUrl = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer);
-
 
891
		url = stationsUrl;
622
	} else {
892
		url += '&zoom='+zoom+
623
		var url = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer)+
893
			'&ne='+NELatLng+
624
			'&formatRetour=jsonP'+
894
			'&sw='+SWLatLng;
625
			'&callback=?';
895
		requeteChargementPoints = $.getJSON(url, function (stationsFiltrees) {
626
		$.getJSON(url, function (stationsFiltrees) {
896
			stations = stationsFiltrees;
627
			stations = stationsFiltrees;
897
			nt = ntAFiltrer;
628
			nt = ntAFiltrer;
898
			$('#taxon-'+nt).addClass('taxon-actif');
629
			$('#taxon-'+nt).addClass('taxon-actif');
899
			rafraichirMarqueurs(stations);
630
			rafraichirCarte();
900
		});
631
		});
Line 901... Line 632...
901
	}
632
	}
902
};
633
};
Line 903... Line -...
903
 
-
 
904
/*+--------------------------------------------------------------------------------------------------------+*/
-
 
905
// FONCTIONS UTILITAIRES
-
 
906
 
-
 
907
function ouvrirPopUp(element, nomPopUp, event) {
-
 
908
	var options = 
-
 
909
		'width=650,'+
-
 
910
		'height=600,'+
-
 
911
		'scrollbars=yes,'+
-
 
912
		'directories=no,'+
-
 
913
		'location=no,'+
-
 
914
		'menubar=no,'+
-
 
915
		'status=no,'+
-
 
916
		'toolbar=no';
-
 
917
	var popUp = window.open(element.href, nomPopUp, options);
-
 
918
	if (window.focus) {
-
 
919
		popUp.focus();
-
 
920
	}
-
 
921
	return arreter(event);
-
 
922
};
-
 
923
 
-
 
924
function ouvrirNouvelleFenetre(element, event) {
-
 
925
	window.open(element.href);
634
 
926
	return arreter(event);
635
/*+--------------------------------------------------------------------------------------------------------+*/
927
}
636
// FONCTIONS UTILITAIRES
928
 
637
 
929
function arreter(event) {
638
function arreter(event) {
930
	if (event.stopPropagation) {
639
	if (event.stopPropagation) {
931
		event.stopPropagation();
-
 
932
	} else if (window.event) {
-
 
933
		window.event.cancelBubble = true;
-
 
934
	}
-
 
935
	if (event.preventDefault) {
640
		event.stopPropagation();
936
		event.preventDefault();
641
	} else if (window.event) {
Line 937... Line 642...
937
	}
642
		window.event.cancelBubble = true;
938
	event.returnValue = false;
643
	}
Line 1023... Line 728...
1023
	} else {
728
	} else {
1024
		msg = "La variable vaut null.";
729
		msg = "La variable vaut null.";
1025
	}
730
	}
1026
	console.log(msg);
731
	console.log(msg);
1027
}
732
}
1028
733
 
-
 
734
function trim (chaine) {
-
 
735
	return chaine.replace(/^\s+/g, '').replace(/\s+$/g, '');
-
 
736
}
-
 
737