-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeSmetUI-OriginalTesting.js
executable file
·184 lines (155 loc) · 5.62 KB
/
DeSmetUI-OriginalTesting.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
$(document).ready( function () {
$("#layers").append("<p>Text added</p>");
var letterObjects = {};
var markerObjects = {};
var basicTest = encodeURI("https://www.googleapis.com/fusiontables/v1/query?sql=SELECT Type FROM 1m_zdoEY-EE81h4bjZYNkAAtHeiMmmkuBX5S5VB8 WHERE Card = 'Glasses of Urza'&key=AIzaSyCCiTJbrAoe15VipHG5QA2YkMjL3FTgq5Q&typed=true&callback=?");
var myString;
var StLouis = new google.maps.LatLng(38.78587,-90.326206);
var infoWindow = function (marker) {
$('#map-canvas').gmap('openInfoWindow', {'content': "Sent to " + marker.letter.recipient + " on " + marker.letter.date + "."}, marker);
return;
};
var pathRender = function (marker) {
var startPoint = marker.letter.location.replace(/ /g,'').split(',');
startPoint = new google.maps.LatLng(startPoint[0],startPoint[1]);
var PathOpts = {
path: [startPoint,StLouis],
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 5
};
$('#map-canvas').gmap('addShape', 'Polyline', PathOpts);
};
var animateLetters = function () {
var period = 1000; // ms
var markerIndex = 0;
var stopLoop = Object.keys(markerObjects).length;
(function myLoop (i) {
setTimeout(function () {
var marker = markerObjects[markerIndex].val(this);
marker['0'].set('visible', true);
console.log(marker['0'].letter.date);
markerIndex++;
if (--i) myLoop(i); // decrement i and call myLoop again if i > 0
}, period)
})(stopLoop); //anonymous function called with the number of iterations as the argument
};
$.ajax({
type: "GET",
url: basicTest,
dataType: "jsonp",
success: function (jsonResp) {
var data = jsonResp['rows'];
myString = data[0][0];
},
error: function () { alert("AJAX error!") }
});
var testQuery = encodeURI("https://www.googleapis.com/fusiontables/v1/query?sql=SELECT * FROM 1eja-Sf9fKtfUyWs7gbPVeXC8O45JbIVjWiEtZDE WHERE Recipient = 'Campbell'&key=AIzaSyCCiTJbrAoe15VipHG5QA2YkMjL3FTgq5Q&typed=true&callback=?");
var testLatLng = [];
$.ajax({
type: "GET",
url: testQuery,
dataType: "jsonp",
success: function (jsonResp) {
var data = jsonResp['rows'];
testLatLng.push(data[0][6]);
},
error: function () { alert("AJAX error!") }
});
var mapOptions = {
center: new google.maps.LatLng(47, -114),
zoom: 8,
mapTypeId: google.maps.MapTypeId.TERRAIN,
mapControl: true,
mapTypeControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
MapTypeIds: (google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.TERRAIN)
}
};
$("#map-canvas").gmap(mapOptions);
var myMap = $("#map-canvas").gmap('get','map');
var Missoula = new google.maps.LatLng(46.870,-114.019);
$("#layers").append("<p>Missoula position " + Missoula.toString() + "</p>");
var GreatFalls = new google.maps.LatLng(47.506,-111.305);
$("#AddMarker").click(function () {
/*var Marker1 = $("#map-canvas").gmap('addMarker', {'position': '47,-114', 'animation': google.maps.Animation.DROP});
Marker1.click(function () {
$('#map-canvas').gmap('openInfoWindow', {'content': 'Hello World!'}, this);
});
var Marker2 = $('#map-canvas').gmap('addMarker', {'position': GreatFalls,'bounds':'false','animation':google.maps.Animation.DROP});
var Marker3 = $('#map-canvas').gmap('addMarker', {'position': Missoula,'bounds':'false', 'animation': google.maps.Animation.DROP});
Marker3.click(function () {
$('#map-canvas').gmap('openInfoWindow', {'content': myString}, this);
});
var Marker4 = $('#map-canvas').gmap('addMarker', {'position': testLatLng[0], 'bounds':'false'});*/
var fullQuery = encodeURI("https://www.googleapis.com/fusiontables/v1/query?sql=SELECT * FROM 1eja-Sf9fKtfUyWs7gbPVeXC8O45JbIVjWiEtZDE WHERE Location > '' ORDER BY Date&key=AIzaSyCCiTJbrAoe15VipHG5QA2YkMjL3FTgq5Q&typed=true&callback=?");
$.ajax({
type: "GET",
url: fullQuery,
dataType: "jsonp",
success: function (jsonResp) {
var data = jsonResp['rows'];
for (var i in data) {
var letter = {
date: data[i][0],
author: data[i][1],
recipient: data[i][2],
locationName: data[i][3],
information: data[i][4],
location: data[i][6],
};
letterObjects[i] = letter;
markerObjects[i] = $('#map-canvas').gmap('addMarker', {
'position': letter.location,
'bounds':'false',
'animation':'none',
'optimized':'false',
/*'icon': {
path: postPath,
fillColor: 'blue',
fillOpacity: 0.5
},*/
'icon': './mapbox-maki/src/post-24.svg',
'visible': false,
'letter':letter
});
};
for (var j in Object.keys(markerObjects)) {
markerObjects[j].click(function () {
infoWindow(this);
});
markerObjects[j].dblclick(function () {
pathRender(this);
});
};
},
error: function () { alert("AJAX error!") }
});
$('#controls').append("<p>Click an icon to see the info. Double-click to see the delivery path. (Animation not currently setup.)</p>");
});
$("#AddPath").click(function() {
animateLetters();
/*var PathOpts = {
path: [new google.maps.LatLng(47,-114),GreatFalls,Missoula],
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 5
};
$("#map-canvas").gmap('addShape', 'Polyline', PathOpts);*/
});
$("#AddFusion").click(function() {
$('#map-canvas').gmap('loadFusion', {
query: {
select: 'Location',
'from': '1eja-Sf9fKtfUyWs7gbPVeXC8O45JbIVjWiEtZDE'
},
styles: [{
markerOptions: {
iconName: "post_office"
}
}],
suppressInfoWindows: true
});
});
});