Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 980 Rev 1032
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/cel-jrest/CelWidgetMap/icone-groupe?type={type}&nbre={nbre}'
7
var groupeImageUrlTpl = 'http://localhost/jrest/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 60... Line 60...
60
	initialiserCarte();
60
	initialiserCarte();
61
	initialiserGestionnaireMarqueurs()
61
	initialiserGestionnaireMarqueurs()
62
	initialiserInfoBulle();
62
	initialiserInfoBulle();
63
	initialiserFormulaireContact();
63
	initialiserFormulaireContact();
64
	chargerLimitesCommunales();
64
	chargerLimitesCommunales();
65
	rafraichirCarte();
65
	attribuerListenerCarte();
-
 
66
	programmerRafraichissementCarte();
66
}
67
}
Line 67... Line 68...
67
 
68
 
68
/*+--------------------------------------------------------------------------------------------------------+*/
69
/*+--------------------------------------------------------------------------------------------------------+*/
Line 138... Line 139...
138
		}
139
		}
139
	}
140
	}
140
}
141
}
141
var listener = null;
142
var listener = null;
142
var timer = null;
143
var timer = null;
143
function rafraichirCarte() {
144
function attribuerListenerCarte() {
144
	
-
 
145
	listener = google.maps.event.addListener(map, 'bounds_changed', function(){
145
	listener = google.maps.event.addListener(map, 'bounds_changed', function(){
146
		
-
 
147
		if(timer != null) {
-
 
148
	        window.clearTimeout(timer);
146
		programmerRafraichissementCarte();
149
	    }
147
	});
150
	   
-
 
151
		timer = window.setTimeout(function() {
148
	listener = google.maps.event.addListener(map, 'zoom_changed', function(){
152
			var zoom = map.getZoom();
149
		programmerRafraichissementCarte();
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
	});
150
	});
158
}
151
}
-
 
152
function programmerRafraichissementCarte() {
-
 
153
	if(timer != null) {
-
 
154
        window.clearTimeout(timer);
-
 
155
    }   
-
 
156
	timer = window.setTimeout(function() {
-
 
157
		var zoom = map.getZoom();
-
 
158
		var NELatLng = map.getBounds().getNorthEast().lat()+'|'+map.getBounds().getNorthEast().lng();
-
 
159
		var SWLatLng = map.getBounds().getSouthWest().lat()+'|'+map.getBounds().getSouthWest().lng();
-
 
160
		chargerMarqueurs(zoom, NELatLng, SWLatLng);
-
 
161
    }, 400);		
-
 
162
}
Line 159... Line 163...
159
 
163
 
Line 160... Line 164...
160
function collecterBorduresEtChargerMarqueurs() {
164
function collecterBorduresEtChargerMarqueurs() {
Line 161... Line 165...
161
 
165
 
162
}
166
}
163
 
167
 
164
var premierChargement = true;
-
 
165
var marqueurs = new Array();
168
var premierChargement = true;
166
function chargerMarqueurs(zoom, NELatLng, SWLatLng) {
169
var marqueurs = new Array();
167
	google.maps.event.removeListener(listener);
170
function chargerMarqueurs(zoom, NELatLng, SWLatLng) {
168
	var url = stationsUrl+
171
	var url = stationsUrl+
Line -... Line 172...
-
 
172
		'&zoom='+zoom+
-
 
173
		'&ne='+NELatLng+
-
 
174
		'&sw='+SWLatLng;
-
 
175
	
169
		'&zoom='+zoom+
176
	if(infoBulleOuverte) {
Line 170... Line 177...
170
		'&ne='+NELatLng+
177
		return;
171
		'&sw='+SWLatLng;
178
	}
172
	
179
	
173
	$.getJSON(url, function(data) {
180
	$.getJSON(url, function(data) {
Line 174... Line 181...
174
		
181
		
175
		$.each(marqueurs, function(index, marqueur) {
182
		$.each(marqueurs, function(index, marqueur) {
176
			marqueur.setMap(null);
-
 
177
		});
-
 
178
		marqueurs = new Array();
-
 
Line 179... Line 183...
179
		
183
			marqueur.setMap(null);
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
			
184
		});
188
			/*if(premierChargement) {
185
		marqueurs = new Array();
189
				var maLatLng = null;
186
		
190
				maLatLng = new google.maps.LatLng(station['lat'], station['lng']);
187
		stations = data;
191
				bounds.extend(maLatLng);
-
 
192
			}*/
-
 
193
			
-
 
194
			if(station != null) {
-
 
195
				marqueurs.push(creerMarqueur(station));
-
 
196
			}
-
 
197
        });
188
		afficherTitreCarte();
198
		
189
		
Line 199... Line 190...
199
		/*if(premierChargement) {
190
		$.each(stations.points, function (index, station) {		
200
			map.fitBounds(bounds);
191
			if(station != null) {
Line 218... Line 209...
218
	attribuerListenerClick(marqueur, station['id']);
209
	attribuerListenerClick(marqueur, station['id']);
219
	marqueur.setMap(map);
210
	marqueur.setMap(map);
220
    return marqueur;
211
    return marqueur;
221
}
212
}
Line 222... Line 213...
222
 
213
 
Line 223... Line 214...
223
function rafraichirCarteSauv() {
214
function programmerRafraichissementCarteSauv() {
224
	
215
	
225
	var points = [];
216
	var points = [];
226
	var bounds = new google.maps.LatLngBounds();
217
	var bounds = new google.maps.LatLngBounds();
Line 293... Line 284...
293
	} else if (etreMarqueurGroupe(id)) {
284
	} else if (etreMarqueurGroupe(id)) {
294
		google.maps.event.addListener(marqueur, 'click', surClickGroupe);
285
		google.maps.event.addListener(marqueur, 'click', surClickGroupe);
295
	}
286
	}
296
}
287
}
Line 297... Line 288...
297
 
288
 
298
function surClickMarqueur() {
289
function surClickMarqueur(event) {
299
	pointClique =  this;
290
	pointClique =  this;
300
	infoBulle.open(map, this);
-
 
301
	//centrerInfoBulle();
291
	infoBulle.open(map, this);
302
	actualiserPagineur();
292
	actualiserPagineur();
303
	afficherInfoBulle();
293
	afficherInfoBulle();
304
	chargerObs(0, 0);
294
	programmerRafraichissementCarte();
Line 305... Line 295...
305
}
295
}
306
 
296
 
307
function surClickGroupe() {
297
function surClickGroupe() {
Line 350... Line 340...
350
	map.fitBounds(bounds);
340
	map.fitBounds(bounds);
351
}
341
}
Line 352... Line 342...
352
 
342
 
353
/*+--------------------------------------------------------------------------------------------------------+*/
343
/*+--------------------------------------------------------------------------------------------------------+*/
354
// INFO BULLE
-
 
-
 
344
// INFO BULLE
355
 
345
var infoBulleOuverte = false;
356
function initialiserInfoBulle() {
346
function initialiserInfoBulle() {
357
	google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle);
347
	google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle);
358
	google.maps.event.addListener(infoBulle, 'closeclick', surFermetureInfoBulle);
348
	google.maps.event.addListener(infoBulle, 'closeclick', surFermetureInfoBulle);
359
	google.maps.event.addListener(infoBulle, 'content_changed', definirLargeurInfoBulle);
349
	google.maps.event.addListener(infoBulle, 'content_changed', definirLargeurInfoBulle);
Line 360... Line 350...
360
}
350
}
-
 
351
 
361
 
352
function surFermetureInfoBulle() {
362
function surFermetureInfoBulle() {
353
	infoBulleOuverte = false;
Line 363... Line 354...
363
	//deplacerCarteSurPointClique();
354
	programmerRafraichissementCarte();
364
}
355
}
365
 
356
 
Line 374... Line 365...
374
function afficherInfoBulle() {
365
function afficherInfoBulle() {
375
	var obsHtml = $("#tpl-obs").html();
366
	var obsHtml = $("#tpl-obs").html();
376
	var largeur = definirLargeurInfoBulle();
367
	var largeur = definirLargeurInfoBulle();
377
	obsHtml = obsHtml.replace(/\{largeur\}/, largeur);
368
	obsHtml = obsHtml.replace(/\{largeur\}/, largeur);
378
	infoBulle.setContent(obsHtml);
369
	infoBulle.setContent(obsHtml);
-
 
370
	infoBulleOuverte = true;
379
}
371
}
Line 380... Line 372...
380
 
372
 
381
function definirLargeurInfoBulle() {
373
function definirLargeurInfoBulle() {
382
	var largeurViewPort = $(window).width();
374
	var largeurViewPort = $(window).width();
Line 599... Line 591...
599
				'<p class="cel-legende-vei">'+'Image n°' + (currentIndex + 1) + ' sur ' + currentArray.length +'<\/p>'+	
591
				'<p class="cel-legende-vei">'+'Image n°' + (currentIndex + 1) + ' sur ' + currentArray.length +'<\/p>'+	
600
				(titre && titre.length ? '<p>'+info+'<\/p>' : '' )+
592
				(titre && titre.length ? '<p>'+info+'<\/p>' : '' )+
601
				'<\/div>';
593
				'<\/div>';
602
			return tpl;
594
			return tpl;
603
		}
595
		}
604
		}).live('click', function(e) {
596
	}).live('click', function(e) {
605
			if (e.stopPropagation) {
597
		if (e.stopPropagation) {
606
				e.stopPropagation();
598
			e.stopPropagation();
607
			}
599
		}
608
			return false;
600
		return false;
609
		});
601
	});
610
}
602
}
Line 611... Line 603...
611
 
603
 
612
function ajouterFomulaireContact(element) {
604
function ajouterFomulaireContact(element) {
613
	$(element).fancybox({
605
	$(element).fancybox({
Line 819... Line 811...
819
		var url = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer);
811
		var url = stationsUrl.replace(/num_taxon=[*0-9]+/, 'num_taxon='+ntAFiltrer);
820
		$.getJSON(url, function (stationsFiltrees) {
812
		$.getJSON(url, function (stationsFiltrees) {
821
			stations = stationsFiltrees;
813
			stations = stationsFiltrees;
822
			nt = ntAFiltrer;
814
			nt = ntAFiltrer;
823
			$('#taxon-'+nt).addClass('taxon-actif');
815
			$('#taxon-'+nt).addClass('taxon-actif');
824
			rafraichirCarte();
-
 
825
		});
816
		});
826
	}
817
	}
827
};
818
};
Line 828... Line 819...
828
 
819