Subversion Repositories Sites.obs-saisons.fr

Rev

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

Rev 270 Rev 273
Line 1... Line 1...
1
var tableau_couleurs = {"Particulier": "#A9582B", "Établissement scolaire" :"#8DC7B8",
1
var tableau_couleurs = {"particulier": "#A9582B", "etablissement_scolaire" :"#8DC7B8",
2
						"Association": "#ED9355","Professionnel": "#A7BD5B",
2
						"association": "#0000FF","professionnel": "#A7BD5B",
3
						"Autre": "#FFC730","Inconnu": "#0000FF"};
3
						"autre": "#FFC730"};
Line 4... Line 4...
4
 
4
 
-
 
5
var infowindow = new google.maps.InfoWindow();
-
 
6
var types_affiches = new Array();
Line 5... Line 7...
5
var infowindow = new google.maps.InfoWindow();
7
var marqueurs = new Array();
6
 
8
 
7
function getUrlBaseJrest() {
9
function getUrlBaseJrest() {
Line 41... Line 43...
41
		var stats = data.stats;
43
		var stats = data.stats;
Line 42... Line 44...
42
				
44
				
43
		for(i in infos_stations) {
45
		for(i in infos_stations) {
44
			creerEtAjouterMarqueur(i, infos_stations[i]);
46
			creerEtAjouterMarqueur(i, infos_stations[i]);
45
		}
47
		}
46
		mettreAJourStats(stats);
48
		genererLegende(stats);
47
	});
49
	});
Line 48... Line 50...
48
}
50
}
Line 53... Line 55...
53
	var image = getUrlBaseJrest()+"OdsMarqueur/point?couleurs="+chaine_couleur;
55
	var image = getUrlBaseJrest()+"OdsMarqueur/point?couleurs="+chaine_couleur;
Line 54... Line 56...
54
    
56
    
55
    return image;
57
    return image;
Line 56... Line 58...
56
}
58
}
-
 
59
 
57
 
60
function genererLegende(stats) {	
58
function mettreAJourStats(stats) {
61
	chaine_legende = '<div class="critere" id="legende">';	
59
	for(i in stats) {
62
	for(i in stats) {
60
		if(i != 'total') {
63
		if(i != 'total') {
61
			var id_legende = '#type_'+i.removeDiacritics().replace(' ','_');
64
			var intitule_type = i.formaterTypePourBalise();
-
 
65
			var id_legende = 'type_'+intitule_type;
-
 
66
			var legende = i+' ('+stats[i]+')';
-
 
67
			var couleur = tableau_couleurs[intitule_type];
-
 
68
			chaine_legende += '<input class="selecteur_type" type="checkbox" value="'+intitule_type+'" id="selecteur_'+id_legende+'" />'+
-
 
69
							  '<span class="legende" style="background-color:'+couleur+'"></span>'+
62
			var legende = $(id_legende).text();
70
							  '<label id="'+id_legende+'">'+legende+'</label>'+
63
			$(id_legende).text(legende+' ('+stats[i]+')');
71
							  '<br />';
64
		} else {
72
		} else {
65
			$('#conteneur_nb_stations').text(stats[i]+' stations au total');
73
			$('#conteneur_nb_stations').text(stats[i]+' stations au total');
-
 
74
		}
-
 
75
	}
-
 
76
	chaine_legende += '</div>';
-
 
77
	$("#conteneur_legende").html(chaine_legende);
-
 
78
	
-
 
79
	$('.selecteur_type').change(function() {
-
 
80
		types_affiches = new Array();
-
 
81
		$('.selecteur_type:checked').each(function(){
-
 
82
			types_affiches.push($(this).attr("id").replace("selecteur_type_",'')); 
-
 
83
		}); 
66
		}
84
		afficherMarqueursSelectionnes();
Line 67... Line 85...
67
	}
85
	})
Line 68... Line 86...
68
}
86
}
69
 
-
 
-
 
87
 
70
function creerEtAjouterMarqueur(id_marqueur, infos_station) {
88
function creerEtAjouterMarqueur(id_marqueur, infos_station) {
71
	
89
	
72
	latlng = new google.maps.LatLng(infos_station['latitude'],infos_station['longitude']);
90
	latlng = new google.maps.LatLng(infos_station['latitude'],infos_station['longitude']);
Line 73... Line 91...
73
		
91
	var intitule_type = infos_station['type_participant'].formaterTypePourBalise();
74
	var chaine_couleur = tableau_couleurs[infos_station['type_participant']];	
92
	var chaine_couleur = tableau_couleurs[intitule_type];	
75
    var image = obtenirImagePourChaineCouleur(chaine_couleur);
93
    var image = obtenirImagePourChaineCouleur(chaine_couleur);
-
 
94
    var nom_station = infos_station['nom'];
76
    var nom_station = infos_station['nom'];
95
    	
77
    	
96
 	var marqueur_station = new google.maps.Marker({
78
 	var marqueur_station = new google.maps.Marker({
97
	      position: latlng,
Line 79... Line 98...
79
	      position: latlng,
98
	      icon:image,
Line 91... Line 110...
91
	});
110
	});
Line 92... Line 111...
92
	
111
	
93
 	marqueur_station.setDraggable(false);
112
 	marqueur_station.setDraggable(false);
Line 94... Line 113...
94
 	marqueur_station.setClickable(true);
113
 	marqueur_station.setClickable(true);
-
 
114
		
-
 
115
 	marqueur_station.setMap(map); 	
-
 
116
 	marqueurs.push(marqueur_station);
-
 
117
}
-
 
118
 
-
 
119
function afficherMarqueursSelectionnes() {
-
 
120
	for(i in marqueurs) {
-
 
121
		var afficher = (types_affiches.length == 0 || jQuery.inArray(marqueurs[i].code, types_affiches) > -1) ? true : false;
95
		
122
		marqueurs[i].setVisible(afficher);
Line 96... Line 123...
96
 	marqueur_station.setMap(map); 
123
	}
Line 97... Line 124...
97
}
124
}
Line 114... Line 141...
114
 
141
 
115
	
142
	
Line 116... Line -...
116
	return contenu_fenetre;
-
 
117
}
-
 
118
 
-
 
119
function genererLegende() {
-
 
120
	
-
 
121
	chaine_legende = '<div class="critere" id="legende">';
-
 
122
	
-
 
123
	for(i in tableau_couleurs) {
-
 
124
		chaine_legende += '<span class="legende" style="background-color:'+tableau_couleurs[i]+'"></span>';
-
 
125
		chaine_legende += '<label id="type_'+i.removeDiacritics().replace(' ','_')+'">'+i+'</label><br />';
-
 
126
	}
-
 
127
	
-
 
128
	chaine_legende += '</div>';
-
 
129
	
-
 
130
	$("#conteneur_legende").html(chaine_legende);
143
	return contenu_fenetre;
Line 131... Line 144...
131
}
144
}
132
 
145
 
Line 155... Line 168...
155
	return '<a class="lien_vers_profil" href="http://obs-saisons.fr/user/'+id+'"> '+pseudo+' </a>';
168
	return '<a class="lien_vers_profil" href="http://obs-saisons.fr/user/'+id+'"> '+pseudo+' </a>';
156
}
169
}
Line 157... Line 170...
157
 
170
 
158
$('#map_canvas').ready(function() {
171
$('#map_canvas').ready(function() {
159
	initialiserCarte();
-
 
160
	genererLegende();
172
	initialiserCarte();
Line -... Line 173...
-
 
173
});
-
 
174
 
-
 
175
String.prototype.formaterTypePourBalise = function() {
-
 
176
	var s = this;
-
 
177
	return s.removeDiacritics().replace(' ','_').toLowerCase();
161
});
178
}
162
 
179
 
163
String.prototype.removeDiacritics = function() {
180
String.prototype.removeDiacritics = function() {
164
	var diacritics = [
181
	var diacritics = [
165
	    [/[\300-\306]/g, 'A'],
182
	    [/[\300-\306]/g, 'A'],