a2f1864cf8f6f3499d22b5579efb7683141d1df4
1 /***************************************************************************
2 * Copyright (C) 2003-2011 Polytechnique.org *
3 * http://opensource.polytechnique.org/ *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19 ***************************************************************************/
21 // http://code.google.com/apis/maps/documentation/javascript/
22 // http://code.google.com/p/google-maps-utility-library-v3/wiki
/Libraries
24 function map_initialize()
26 var latlng
= new google
.maps
.LatLng(0, 0);
30 mapTypeId
: google
.maps
.MapTypeId
.ROADMAP
32 var map
= new google
.maps
.Map($('#map_canvas').get(0), myOptions
);
34 $.xget(window
.location
.href
, {ajax
: true}, function(json_data
) {
35 var data
= jQuery
.parseJSON(json_data
);
37 var count
= dots
.length
;
40 for (var i
= 0; i
< count
; ++i
) {
41 var latLng
= new google
.maps
.LatLng(dots
[i
].latitude
, dots
[i
].longitude
);
42 var color
= promos_to_color(dots
[i
].promo
);
44 if (dots
[i
].hrpid
.search(',') > -1) {
45 var hrpids
= dots
[i
].hrpid
.split(',');
46 var names
= dots
[i
].name
.split(',');
47 var link_array
= new Array();
49 for (var j
= 0; j
< hrpids
.length
; ++j
) {
50 link_array
[j
] = '<a href="profile/' + hrpids[j] + '">' + names[j] + '</a>';
52 var link
= link_array
.join('<br />');
54 var link
= '<a href="profile/' + dots[i].hrpid + '">' + dots[i].name + '</a>';
57 var marker
= new MarkerWithLabel({
60 'labelClass': 'marker_label'
62 marker
.bindTo('icon', new ColoredIcon(color
));
63 marker
.set('color', color
);
66 var mc
= new MarkerClusterer(map
, markers
);
70 function ColoredIcon(color
)
72 this.set('starcolor', null);
73 this.set('color', color
);
74 this.set('icon', 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|' + color
);
77 ColoredIcon
.prototype = new google
.maps
.MVCObject();
79 var colors
= new Array();
80 colors
['red'] = 'ff0000';
81 colors
['yellow'] = 'ffff00';
82 colors
['blue'] = '0000ff';
83 colors
['green'] = '00ff00';
84 colors
['gray'] = '606060';
86 function promos_to_color(promos
)
88 var promos_array
= promos
.split(',');
89 var length
= promos_array
.length
;
92 return colors
[promo_to_color(promos
)];
95 var color_array
= new Array();
96 for (var i
= 0; i
< length
; ++i
) {
97 color_array
[i
] = promo_to_color(promos_array
[i
]);
100 return color_average(color_array
);
103 function promo_to_color(promo
)
105 var main_education
= promo
.charAt(0);
107 switch (main_education
)
110 var year_promo
= promo
.substr(1);
111 if ((year_promo
% 2) == 0) {
125 function color_average(color_array
)
127 var length
= color_array
.length
;
128 var rbg
= new Array(0, 0, 0);
130 for (var i
= 0; i
< length
; ++i
) {
131 switch (color_array
[i
])
157 for (var i
= 0; i
< 3; ++i
) {
158 var color
= Math
.floor(rbg
[i
] / length
* 255);
159 var hexa
= color
.toString(16);
160 if (hexa
.length
== 1) {
169 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: