-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
197 lines (157 loc) · 6.23 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//page loading animation part 1
$(window).on('load', function() {
$("#pageLoad").fadeOut('fast');
});
$(document).ready(function() {
//page loading animation part 2
$("#app").fadeIn('fast');});
///////********************************************************************************************************/////////////////////
//Map Functionalities
var image_2017_18 = {
url: 'https://www.projectmap.uomleos.org/a.png',
};
var image_2018_19 = {
url: 'https://www.projectmap.uomleos.org/a.png',
};
var markers = [];
//Map Initialize
var srilanka = { lat: 8.8, lng: 80.7718 };
var map = new google.maps.Map(document.getElementById('map'), {
scaleControl: true,
streetViewControl: true,
fullscreenControl: false,
mapTypeControlOptions: {
position: google.maps.ControlPosition.LEFT_BOTTOM
},
zoom: 7.6,
center: srilanka,
mapTypeId: google.maps.MapTypeId.ROADMAP,
fullscreenControl: true
});
infoWindow = new google.maps.InfoWindow(); // create info window object
var oms = new OverlappingMarkerSpiderfier(map, {
markersWontMove: true,
markersWontHide: true,
basicFormatEvents: true
});
$.get("submit/files/get.php", function(data, status){
var locations = JSON.parse(data);
$('#projectCount').text("planted "+String(locations.length)+" trees");
//UOM LEOS Marker
var coordinates = { lat: 6.7968823, lng: 79.8995894 };
var uom_icon = {
url: 'https://www.projectmap.uomleos.org/b.png',
};
var uom_marker = new google.maps.Marker({
position: coordinates,
url: 'http://www.uomleos.org/',
icon: uom_icon,
animation: google.maps.Animation.BOUNCE,
map: map,
title: "Double click to view www.uomleos.org" , // generate title
name: "Leo Club of University of Moratuwa",
address:"University of Moratuwa, Bandaranayake Mawatha, Katubedda, Moratuwa."
});
oms.addMarker(uom_marker);
google.maps.event.addListener(uom_marker, 'dblclick', function () { // marker onclick event
//window.location.href = ;
window.open(
'http://www.uomleos.org/',
'_blank' // <- This is what makes it open in a new window.
);
});
//marker hover effect
google.maps.event.addListener(uom_marker, 'spider_click', function () { //
});
google.maps.event.addListener(uom_marker, 'click', function () {
var content = "<b>"+uom_marker.name+"</b><br>"+uom_marker.address+"<br><br>♦ Click on pin to view all projects on this location<br>♦ Double tap to open www.uomleos.org";
infoWindow.setContent(content);
infoWindow.open(map, uom_marker);
});
google.maps.event.addListener(uom_marker, 'mouseover', function () {
var content = "<b>"+uom_marker.name+"</b><br>"+uom_marker.address+"<br><br>♦ Click on pin to view all projects on this location<br>♦ Double tap to open www.uomleos.org";
infoWindow.setContent(content);
infoWindow.open(map, uom_marker);
});
google.maps.event.addListener(uom_marker, 'mouseout', function () {
infoWindow.close();
});
//UOM LEOS MARKER
// Other marker data load
setMarkers(locations);
$("#year").change(function(){
var filter = $("#year").val().trim();
clearMarkers();
if(filter!="0"){
var filteredMarkers = markersYearFilter(locations,filter);
$('#projectCount').text("Planted "+String(filteredMarkers.length)+" trees.");
setMarkers(filteredMarkers);
}else{
setMarkers(locations);
$('#projectCount').text("Planted "+String(locations.length)+" trees.");
}
});
});
//Locations add here
//["Project name",address,lat,lng,Url here]
/*var locations = [
['Golden Nets','X Sports Arena, Mattakkuliya', 6.8135, 79.9724, 'http://www.uomleos.org/2018/04/02/golden-netz/'],
['LEO Youth Camp',"National youth crops tranning center,Naula", 7.7071, 80.6521, 'http://www.uomleos.org/2018/04/01/leo-youth-camp/'],
['Ttest',"National youth crops tranning center,Naula", 7.8071, 80.8521, 'http://www.uomleos.org/2018/04/01/leo-youth-camp/'],
['Ttest',"National youth crops tranning center,Naula", 7.7071, 80.6521, 'http://www.uomleos.org/2018/04/01/leo-youth-camp/'],
['Ttest',"National youth crops tranning center,Naula", 7.9071, 80.7521, 'http://www.uomleos.org/2018/04/01/leo-youth-camp/'],
];*/
function setMarkers(locations){
for (var i = 0; i < locations.length; i++) {
var place = locations[i];
var coordinates = { lat: parseFloat(place.lat), lng: parseFloat(place.lon) };
var image = image_2017_18;
if(place.year=='2018/19'){
image = image_2018_19;
}
var marker = new google.maps.Marker({
position: coordinates,
url: place.url,
icon: image,
animation: google.maps.Animation.DROP,
map: map,
title: "Double click to view "+place.name , // generate title
name: place.name,
address:place.address
});
markers.push(marker);
oms.addMarker(marker);
google.maps.event.addListener(marker, 'dblclick', function () { // marker onclick event
window.open(
this.url,
'_blank' // <- This is what makes it open in a new window.
);
});
//marker hover effect
google.maps.event.addListener(marker, 'spider_click', function () { //
});
google.maps.event.addListener(marker, 'click', function () {
var content = "<b>"+this.address+"</b><br>"+this.name+"<br><br>♦ Click on pin to view all projects on this location<br>♦ Double tap to view project description";
infoWindow.setContent(content);
infoWindow.open(map, this);
});
google.maps.event.addListener(marker, 'mouseout', function () {
infoWindow.close();
});
}
}
function clearMarkers(){
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(null);
}
}
function markersYearFilter(array,filter){
var rtn = [];
for(var i=0;i<array.length;i++){
if(array[i].year==filter){
console.log(array[i]);
rtn.push(array[i]);
}
}
return rtn;
}