1 |
27204
|
antonis.le
|
var prmstr;
|
2 |
|
|
var prmarr;
|
3 |
|
|
var params;
|
4 |
|
|
|
5 |
|
|
var MapStyles = [
|
6 |
|
|
{featureType: "all", stylers: [{ saturation: -80 }]},
|
7 |
|
|
{featureType: "road", stylers: [{ visibility: "off" }]},
|
8 |
|
|
{featureType: "transit", stylers: [{ visibility: "off" }]},
|
9 |
|
|
{featureType: "poi", stylers: [{ visibility: "off" }]},
|
10 |
|
|
{featureType: "landscape", stylers: [{ visibility: "off" }]},
|
11 |
|
|
{featureType: "administrative.land_parcel", stylers: [{ visibility: "off" }]},
|
12 |
|
|
{featureType: "administrative.locality", stylers: [{ visibility: 'off' }]},
|
13 |
|
|
{featureType: "administrative.neighborhood", stylers: [{ visibility: "off" }]},
|
14 |
|
|
{featureType: "administrative.province", stylers: [{ visibility: "off" }]}];
|
15 |
|
|
var mapType = new google.maps.StyledMapType(MapStyles, {name: "Gray"});
|
16 |
|
|
|
17 |
|
|
var MYMARKERS = new Array();
|
18 |
|
|
var MYREPOS = new Array();
|
19 |
|
|
|
20 |
|
|
var MYICONS = new Array();
|
21 |
|
|
MYICONS[0] = "./images/blue_marker.png";
|
22 |
|
|
MYICONS[1] = "./images/green_marker.png";
|
23 |
|
|
MYICONS[2] = "./images/orange_marker.png";
|
24 |
|
|
MYICONS[3] = "./images/red_marker.png";
|
25 |
|
|
MYICONS[4] = "./images/grey_marker.png";
|
26 |
|
|
MYICONS[5] = "http://maps.gstatic.com/mapfiles/ridefinder-images/mm_20_black.png";
|
27 |
|
|
MYICONS[6] = "http://maps.gstatic.com/mapfiles/ridefinder-images/mm_20_purple.png";
|
28 |
|
|
|
29 |
|
|
var MYMAP = {
|
30 |
|
|
map: null,
|
31 |
|
|
bounds: null
|
32 |
|
|
}
|
33 |
|
|
var infoWindow = new google.maps.InfoWindow();
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
MYMAP.init = function(selector, latLng, zoom) {
|
37 |
|
|
var myOptions = {
|
38 |
|
|
zoom:zoom,
|
39 |
|
|
center: latLng,
|
40 |
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
41 |
|
|
mapTypeControlOptions: {
|
42 |
|
|
mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE, 'grey']
|
43 |
|
|
}
|
44 |
|
|
}
|
45 |
|
|
this.map = new google.maps.Map($(selector)[0], myOptions);
|
46 |
|
|
this.bounds = new google.maps.LatLngBounds();
|
47 |
|
|
|
48 |
|
|
this.map.mapTypes.set('grey', mapType);
|
49 |
|
|
this.map.setMapTypeId('grey');
|
50 |
|
|
getRepositories();
|
51 |
|
|
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
var countries = new Array();
|
55 |
|
|
var repotypes = new Array();
|
56 |
|
|
var comptypes = new Array();
|
57 |
|
|
|
58 |
|
|
MYMAP.placeMarkers = function() {
|
59 |
|
|
var cstr = '';
|
60 |
|
|
var comstr = '';
|
61 |
|
|
var tstr = '';
|
62 |
|
|
|
63 |
|
|
$.each(MYREPOS,function(index){
|
64 |
|
|
var name = this.name;
|
65 |
|
|
|
66 |
|
|
// create a new LatLng point for the marker
|
67 |
|
|
var lat = this.lat;
|
68 |
|
|
var lng = this.lon;
|
69 |
|
|
var point = new google.maps.LatLng(this.lat,this.lon);
|
70 |
|
|
|
71 |
|
|
if(repotypes.indexOf(this.type) == -1){
|
72 |
|
|
repotypes.push(this.type);
|
73 |
|
|
tstr += "<img src='"+MYICONS[repotypes.indexOf(this.type)]+"'/>";
|
74 |
|
|
tstr += "<input type='checkbox' class='typebox item' value='"+this.type+"'>"+this.type+"<br />";
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
if(countries.indexOf(this.country) == -1){
|
78 |
|
|
countries.push(this.country);
|
79 |
|
|
//cstr += "<input type='checkbox' class='countrybox item' value='"+this.country+"'>"+this.country+"<br />";
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
if(comptypes.indexOf(this.compatibility) == -1){
|
83 |
|
|
comptypes.push(this.compatibility);
|
84 |
|
|
comstr += "<input type='checkbox' class='compatibilitybox item' value='"+this.compatibility+"'>"+this.compatibility+"<br />";
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
var marker = new google.maps.Marker({
|
88 |
|
|
position: point,
|
89 |
|
|
map: MYMAP.map,
|
90 |
|
|
icon: MYICONS[repotypes.indexOf(this.type)],//<-- change that
|
91 |
|
|
title: name
|
92 |
|
|
});
|
93 |
|
|
|
94 |
|
|
// extend the bounds to include the new point
|
95 |
|
|
MYMAP.bounds.extend(point);
|
96 |
|
|
|
97 |
|
|
var html='<p class="tooltip-header"><a href="http://furkot.icm.edu.pl/openaire/index.php?option=com_openaire&view=datasource&Itemid=134&datasourceId='+this.id+'" target="_blank">'+this.name+'</a></p><p class="tooltip-body"><br />type: '+this.type+'<br />compatibility: '+this.compatibility+'<br />organization:'+this.organization+'<br />country:'+this.country+'</p>';
|
98 |
|
|
google.maps.event.addListener(marker, 'click', function() {
|
99 |
|
|
infoWindow.setContent(html);
|
100 |
|
|
infoWindow.open(MYMAP.map, marker);
|
101 |
|
|
});
|
102 |
|
|
//MYMAP.map.fitBounds(MYMAP.bounds);
|
103 |
|
|
|
104 |
|
|
MYMARKERS[index] = new Object();
|
105 |
|
|
MYMARKERS[index].repo = this;
|
106 |
|
|
MYMARKERS[index].marker = marker;
|
107 |
|
|
|
108 |
|
|
});
|
109 |
|
|
countries.sort();
|
110 |
|
|
cstr = '';
|
111 |
|
|
$.each(countries,function(){
|
112 |
|
|
cstr += "<input type='checkbox' class='countrybox item' value='"+this+"'>"+this+"<br />";
|
113 |
|
|
|
114 |
|
|
});
|
115 |
|
|
|
116 |
|
|
$("#countries").append(cstr);
|
117 |
|
|
$("#compatibility").append(comstr);
|
118 |
|
|
$("#types").append(tstr);
|
119 |
|
|
|
120 |
|
|
//MYMAP.map.fitBounds(MYMAP.bounds);
|
121 |
|
|
//MYMAP.map.setCenter(MYMAP.bounds.getCenter());
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
function getRepositories(){
|
126 |
|
|
var query = "select datasource.id, datasource.name, datasource.type, datasource.compatibility, datasource.latitude, datasource.longitude, organization.name, organization.country from datasource left join datasource_organizations on datasource.datasource_organizations = datasource_organizations.id left join organization on organization.id=datasource_organizations.organization where latitude!='0.0' and longitude!='0.0' and datasource.type LIKE '%Repository%' and datasource.compatibility != 'unknown' and datasource.compatibility!='non compatible'";
|
127 |
|
|
|
128 |
|
|
if(params.country != null){
|
129 |
|
|
query += " and organization.country='"+params.country+"'";
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
$.ajax({
|
133 |
|
|
type: "GET",
|
134 |
|
|
async: false,
|
135 |
|
|
url: "ajaxRouter9.php",
|
136 |
|
|
data: "com=performQuery&query="+query,
|
137 |
|
|
success: function(resp){
|
138 |
|
|
// we have the response
|
139 |
|
|
createMarkersForRepos(JSON.parse(resp));
|
140 |
|
|
},
|
141 |
|
|
error: function(e){
|
142 |
|
|
alert('Error: ' + e);
|
143 |
|
|
}
|
144 |
|
|
});
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
function createMarkersForRepos(repos){
|
148 |
|
|
var len = repos.length;
|
149 |
|
|
var m = MYREPOS.length;
|
150 |
|
|
for(var i=m;i<len+m;i++){
|
151 |
|
|
MYREPOS[i] = new Object();
|
152 |
|
|
//name, type, compatibility, lat, lon, organization, country
|
153 |
|
|
MYREPOS[i].id = repos[i-m][0];
|
154 |
|
|
MYREPOS[i].name = repos[i-m][1];
|
155 |
|
|
MYREPOS[i].type = repos[i-m][2];
|
156 |
|
|
MYREPOS[i].compatibility = repos[i-m][3];
|
157 |
|
|
MYREPOS[i].lat = parseFloat(repos[i-m][4]);
|
158 |
|
|
MYREPOS[i].lon = parseFloat(repos[i-m][5]);
|
159 |
|
|
if(repos[i-m][6]!=null)
|
160 |
|
|
MYREPOS[i].organization = repos[i-m][6];
|
161 |
|
|
else
|
162 |
|
|
MYREPOS[i].organization = "-";
|
163 |
|
|
if(repos[i-m][7]!=null)
|
164 |
|
|
MYREPOS[i].country = repos[i-m][7];
|
165 |
|
|
else
|
166 |
|
|
MYREPOS[i].country = "UNKNOWN";
|
167 |
|
|
}
|
168 |
|
|
}
|
169 |
|
|
|
170 |
|
|
function filter(){
|
171 |
|
|
var countries;
|
172 |
|
|
var countrynames = new Array();
|
173 |
|
|
var comtypes;
|
174 |
|
|
var comptypenames = new Array();
|
175 |
|
|
var dsrctypes;
|
176 |
|
|
var dsrctypenames = new Array();
|
177 |
|
|
|
178 |
|
|
dsrctypes = $(".typebox:checked");
|
179 |
|
|
|
180 |
|
|
$(dsrctypes).each(function(){
|
181 |
|
|
dsrctypenames.push($(this).attr('value'));
|
182 |
|
|
});
|
183 |
|
|
|
184 |
|
|
countries = $(".countrybox:checked");
|
185 |
|
|
|
186 |
|
|
$(countries).each(function(){
|
187 |
|
|
countrynames.push($(this).attr('value'));
|
188 |
|
|
});
|
189 |
|
|
|
190 |
|
|
comtypes = $(".compatibilitybox:checked");
|
191 |
|
|
$(comtypes).each(function(){
|
192 |
|
|
comptypenames.push($(this).attr('value'));
|
193 |
|
|
});
|
194 |
|
|
|
195 |
|
|
//check all the markers, if the country is checked, show the ones that have the right icon, and hide the rest
|
196 |
|
|
$.each(MYMARKERS,function(){
|
197 |
|
|
if(countrynames.indexOf(this.repo.country)!=-1 && comptypenames.indexOf(this.repo.compatibility)!=-1 && dsrctypenames.indexOf(this.repo.type)!=-1){
|
198 |
|
|
this.marker.setMap(MYMAP.map);
|
199 |
|
|
}
|
200 |
|
|
else
|
201 |
|
|
this.marker.setMap(null);
|
202 |
|
|
|
203 |
|
|
});
|
204 |
|
|
|
205 |
|
|
if($(".countrybox:checked").length==$(".countrybox").length){
|
206 |
|
|
$(".checkedcountries p").html("all countries selected");
|
207 |
|
|
}
|
208 |
|
|
else{
|
209 |
|
|
$(".checkedcountries p").html($(".countrybox:checked").length+" countries selected");
|
210 |
|
|
}
|
211 |
|
|
}
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
$(document).ready(function() {
|
215 |
|
|
|
216 |
|
|
prmstr = window.location.search.substr(1);
|
217 |
|
|
prmarr = prmstr.split ("&");
|
218 |
|
|
params = {};
|
219 |
|
|
|
220 |
|
|
for ( var i = 0; i < prmarr.length; i++) {
|
221 |
|
|
var tmparr = prmarr[i].split("=");
|
222 |
|
|
params[tmparr[0]] = tmparr[1];
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
$("#map").css("height","600px").css("width", "90%");
|
226 |
|
|
var myLatLng = new google.maps.LatLng(51.618017,14.487303);
|
227 |
|
|
MYMAP.init('#map', myLatLng, 4);
|
228 |
|
|
MYMAP.placeMarkers();
|
229 |
|
|
|
230 |
|
|
var zoomChangeBoundsListener =
|
231 |
|
|
google.maps.event.addListenerOnce(MYMAP.map, 'bounds_changed', function(event) {
|
232 |
|
|
if (this.getZoom()){
|
233 |
|
|
//if(params.country != null)
|
234 |
|
|
this.setZoom(4);
|
235 |
|
|
//else
|
236 |
|
|
// this.setZoom(3);
|
237 |
|
|
}
|
238 |
|
|
});
|
239 |
|
|
setTimeout(function(){google.maps.event.removeListener(zoomChangeBoundsListener)}, 2000);
|
240 |
|
|
|
241 |
|
|
if(params.country == null)
|
242 |
|
|
$("#countrycol").show();
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
$(".compatibilitybox").attr("checked","checked");
|
246 |
|
|
$(".typebox").attr("checked","checked");
|
247 |
|
|
$(".countrybox").attr("checked","checked");
|
248 |
|
|
filter();
|
249 |
|
|
|
250 |
|
|
$("#call").click(function(){
|
251 |
|
|
$(".countrybox").attr("checked","checked");
|
252 |
|
|
filter();
|
253 |
|
|
});
|
254 |
|
|
|
255 |
|
|
$("#cnone").click(function(){
|
256 |
|
|
$(".countrybox").attr("checked","");
|
257 |
|
|
filter();
|
258 |
|
|
});
|
259 |
|
|
|
260 |
|
|
$(".countrybox").live("click",filter);
|
261 |
|
|
$(".typebox").live("click",filter);
|
262 |
|
|
$(".compatibilitybox").live("click",filter);
|
263 |
|
|
|
264 |
|
|
});
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
|