-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDC2_venues.html
315 lines (279 loc) · 13.5 KB
/
DC2_venues.html
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<script src="http://maps.google.com/maps/api/js?key=AIzaSyBc4IHW1ciwoYpft2N8pXskogxcE2S9lL0&sensor=true"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.7/queue.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style type="text/css">
html, body, #map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.stations, .stations svg {
position: absolute;
}
.stations svg {
width: 100px;
height: 35px;
/*padding-right: 100px;*/
font: 10px sans-serif;
}
.stations circle {
fill: blue;
stroke: black;
stroke-width: 1.5px;
}
.stations polygon {
fill: green;
stroke: black;
stroke-width: 1.5px;
}
.all-pointer-events {
pointer-events: all;
}
.no-pointer-events {
pointer-events: none;
}
.tooltip {
/*position: absolute;*/
/*z-index: 10000000000000;*/
text-align: left;
/*width: 200px;*/
/*height: 300px;*/
padding: 2px;
/*font: 12px sans-serif;*/
background: lightsteelblue;
border: 2px;
border-radius: 4px;
/*pointer-events: none;*/
}
.absolute {
position: absolute;
top: 10px;
left: 10px;
border-radius: 10px;
}
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var map;
Venue_Overlay = function(data) {
console.log(data)
var CalculateStarPoints = function(centerX, centerY, arms, outerRadius, innerRadius) {
var results = "";
var angle = Math.PI / arms;
for (var i = 0; i < 2 * arms; i++) {
// Use outer or inner radius depending on what iteration we are in.
var r = (i & 1) == 0 ? outerRadius : innerRadius;
var currX = centerX + Math.sin(i * angle) * r;
var currY = centerY - Math.cos(i * angle) * r;
// Our first time we simply append the coordinates, subsequet times
// we append a ", " to distinguish each coordinate pair.
if (i == 0) {
results = currX + "," + currY;
}
else {
results += ", " + currX + "," + currY;
}
}
return results;
}
var overlay = new google.maps.OverlayView();
// Add the container when the overlay is added to the map.
overlay.onAdd = function() {
// var layer = d3.select(this.getPanes().overlayLayer)
var layer = d3.select(this.getPanes().overlayMouseTarget)
.append("div")
.attr("class", "stations");
// Draw each marker as a separate SVG element.
// We could use a single SVG, but what size would it have?
overlay.draw = function() {
var projection = this.getProjection(),
padding = 10;
var marker = layer.selectAll("svg")
// .data(d3.entries(data))
.data(data)
.each(transform) // update existing markers
.enter().append("svg:svg")
.each(transform)
.attr("class", "marker")
.attr("class",function(d){
if (d.favorite=='yes') {
return "favorite"}
else {
return "circle"
}
}); // no-pointer-events");
// Add a circle.
layer.selectAll(".circle")
.append("svg:circle")
.attr("class","child")
.attr("r", 4.5)
.attr("cx", padding)
.attr("cy", padding)
.on("mouseenter",Create_Tooltip); //.on("mouseout",Remove_Tooltip);
layer.selectAll(".favorite")
.append("svg:polygon")
.attr("class","child")
.attr('points',CalculateStarPoints( padding, padding, 5, 4.5*7/4, 4.5))
// .attr('stroke-width',1)
// .attr('stroke','#000000')
// .attr('fill','green')
.on("mouseenter",Create_Tooltip); //.on("mouseout",Remove_Tooltip);
// Add a label.
marker.append("svg:rect")
.attr("class","no-pointer-events")
.attr("x", padding + 7)
.attr("y", padding - 7)
.attr("width",function(d){
return d.name.length*7})
.attr("height",15)
.attr("opacity",0.7)
.attr("fill","white");
marker.append("svg:text")
.attr("class","no-pointer-events")
.attr("x", padding + 7)
.attr("y", padding)
.attr("dy", ".36em")
.attr("font-weight","bold")
.style("pointer-events","none")
.text(function(d) {
return d.name;
}); // If the spreadsheet columns change, this is most likely going to have to change.
function transform(d) {
d = new google.maps.LatLng(d.latlon[0], d.latlon[1]);
d = projection.fromLatLngToDivPixel(d);
return d3.select(this)
.style("left", (d.x - padding) + "px")
.style("top", (d.y - padding) + "px");
}
};
function Create_Tooltip(d) {
var this_element = d3.select(this);
// https://developers.google.com/maps/documentation/javascript/infowindows
// http://stackoverflow.com/questions/5634991/styling-google-maps-infowindow
var myLatLng = {lat: d.latlon[0], lng: d.latlon[1]};
var content_string =
'<div class="tooltip">'+
'<h1><a href='+ d.website +' target="_blank"><b>'+ d.name +'</b></a></h1>' +
'<p><b>Seating/Capacity: </b>'+ d.seating +'/'+ d.maxcapacity +'</p>' +
'<p><b>Food: </b>'+ d.food +'</p>' +
'<p><b>Sponsor: </b>'+ d.sponsor +'</p>' +
'<p><b>Security: </b>'+ d.security +'</p>' +
'<p><b>WiFi: </b>'+ d.wifi +'</p>' +
'<p><b>Networking Space: </b>'+ d.separatenetworking +'</p>' +
'<p><b>DC2 Contact: </b><a href="mailto:'+ d.dc2email +'?Subject=DC2%20Venue%20Request" target="_blank">'+ d.dc2contact +'</a></p>' +
'<p>Would you like to <a href="mailto:seang@datacommunitydc.org?Subject=DC2%20Venue%20Sponsor%20Inquiry" target="_blank">Sponsor DC2?</a></p>' +
'</div>';
var infowindow = new google.maps.InfoWindow({
position: myLatLng,
content: content_string
});
infowindow.open(map); // , marker);
}
};
// Bind our overlay to the map…
overlay.setMap(map);
};
// Parse_Master_List = function(text) {
// var venues = new Array();
// var geocoder = new google.maps.Geocoder();
// d3.csv.parse(text).forEach(function(d,i){
//
// var address = d["Address"] + ", " + d["City/State"];
// var latitude, longitude;
// geocoder.geocode( {'address': address}, function(results, status) {
//
// if (status === google.maps.GeocoderStatus.OK) {
// latitude = results[0].geometry.location.lat();
// longitude = results[0].geometry.location.lng();
// } else {
// alert('Geocode was not successful for the following reason: ' + status);
// }
// console.log("address: ",address," Lat/Lon: ",[latitude,longitude])
// });
// venues[i] = {"key":d["Name"], "value":[longitude,latitude]};
// });
// };
function sheetLoaded(venuesSheet) {
// Create the Google Map…
map = new google.maps.Map(d3.select("#map").node(), {
zoom: 12,
center: new google.maps.LatLng(38.8977, -77.0366),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
// Parse the google response
var venues = venuesSheet.feed.entry; // List of objects
var num_venues = venues.length;
var data = new Array();
for (v=0;v<num_venues;v++) {
data.push({
'name':venues[v].gsx$name.$t,
'latlon':[parseFloat(venues[v].gsx$latitude.$t),
parseFloat(venues[v].gsx$longitude.$t)],
'seating':venues[v].gsx$seating.$t,
'maxcapacity':venues[v].gsx$maxcapacity.$t,
'food':venues[v].gsx$food.$t,
'sponsor':venues[v].gsx$sponsor.$t,
'security':venues[v].gsx$security.$t,
'wifi':venues[v].gsx$wifi.$t,
'separatenetworking':venues[v].gsx$separatenetworking.$t,
'favorite':venues[v].gsx$favorite.$t,
'website':venues[v].gsx$website.$t,
'dc2contact':venues[v].gsx$dc2contact.$t,
'dc2email':venues[v].gsx$dc2email.$t,
});
};
Venue_Overlay(data);
// console.log(venuesSheet);
// d3.text("DC2_Master_Space_List-Sheet1.csv", function(text) {
// queue()
// .defer(Parse_Master_List,text)
// .defer(Venue_Overlay,venuesSheet)
// .await(function(error, file1, file2) { console.log(file1, file2); });
// });
};
// You'll probably also want to convert your columns to numbers, because they'll be strings by default.
// Assume they are all numbers, you could say:
//d3.text("data/testnh.csv", function(text) {
// var data = d3.csv.parseRows(text).map(function(row) {
// return row.map(function(value) {
// return +value;
// });
// });
// console.log(data);
//});
//var venues;
//function loadData() {
// var url="https://docs.google.com/spreadsheets/d/1XUDG6h0bZ8RDofSfIy1Xc_QxoijktpmWTU-i4cILcow/pub?gid=0&single=true&output=csv";
// xmlhttp=new XMLHttpRequest();
// xmlhttp.onreadystatechange = function() {
// if(xmlhttp.readyState == 4 && xmlhttp.status==200){
// venues = xmlhttp.responseText
//// document.getElementById("display").innerHTML = xmlhttp.responseText;
// }
// };
// xmlhttp.open("GET",url,true);
// xmlhttp.send(null);
//}
</script>
<!-- Venue Application Button -->
<div>
<!-- <button type="button" class="btn btn-primary">Add Your Venue</button> -->
<a href="https://docs.google.com/forms/d/e/1FAIpQLSe9V-tW_B2LaYtzGLcDuwa_lKa056hN_usQiHx-v9pzkVuU2A/viewform" class="btn btn-info absolute" style="background-color:rgb(52,93,171)" role="button"><h3>Want to host a DC2 Event?</h3><h4>Click here to add your event</h4></a>
</div>
</body>
<!--<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBcY0Lc0gM2_PG8vRQqPiUs-vJtszG_jUY&signed_in=true&callback=InitMap" async defer></script>-->
<!--<script src="https://spreadsheets.google.com/feeds/cells/1XUDG6h0bZ8RDofSfIy1Xc_QxoijktpmWTU-i4cILcow/public/values?alt=json-in-script&callback=sheetLoaded"></script>-->
<!--<script src="https://spreadsheets.google.com/feeds/cells/1XUDG6h0bZ8RDofSfIy1Xc_QxoijktpmWTU-i4cILcow/od6/public/values?alt=json-in-script&callback=sheetLoaded"></script>-->
<script src="https://spreadsheets.google.com/feeds/list/1XUDG6h0bZ8RDofSfIy1Xc_QxoijktpmWTU-i4cILcow/od6/public/values?alt=json-in-script&callback=sheetLoaded"></script>
<!--<script src="https://spreadsheets.google.com/feeds/cells/1XUDG6h0bZ8RDofSfIy1Xc_QxoijktpmWTU-i4cILcow/-u3c65o/public/values?alt=json-in-script&callback=sheetLoaded"></script>-->
</html>