-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
316 lines (286 loc) · 9.74 KB
/
index.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
316
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>The Marauder's Map</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.18/esri/css/esri.css">
<style>
html, body, #map {
height:100%;
width:100%;
margin:0;
padding:0;
}
.esriScalebar{
padding: 20px 20px;
}
#map{
padding:0;
}
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="https://js.arcgis.com/3.18/"></script>
<script>
var QueryString = function () {
// This function is anonymous, is executed immediately and
// the return value is assigned to QueryString!
var query_string = {};
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
// If first entry with this name
if (typeof query_string[pair[0]] === "undefined") {
query_string[pair[0]] = decodeURIComponent(pair[1]);
// If second entry with this name
} else if (typeof query_string[pair[0]] === "string") {
var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
query_string[pair[0]] = arr;
// If third or later entry with this name
} else {
query_string[pair[0]].push(decodeURIComponent(pair[1]));
}
}
return query_string;
}();
</script>
<style>
#heart53100 {position:absolute;
top:600px;
left:20px;
z-index:2;
height:4em;
width:18em;
font-size:1.5em;
padding: 1em;
color:black;
text-transform: capitalize;
font-family: 'Pirata One', cursive;
color: darkred;
}
</style>
<link href="https://fonts.googleapis.com/css?family=Pirata+One" rel="stylesheet">
<script>
// http://stackoverflow.com/questions/3885817/how-do-i-check-that-a-number-is-float-or-integer
function isFloat(n){
return Number(n) === n && n % 1 !== 0;
}
// http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
function getParameterByName(name, url) {
if (!url) {
url = window.location.href;
}
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var group = getParameterByName("group")
if (group == null || group == "") {
group = "hackduke"
}
var centerPos = [-78.93948,36.00328];
var foo = getParameterByName("lon")
if (foo == null || foo == "") {
} else {
console.log(foo)
centerPos[0] = parseFloat(foo);
}
var foo = getParameterByName("lat")
if (foo == null || foo == "") {
} else {
console.log(foo)
centerPos[1] = parseFloat(foo);
}
</script>
</head>
<body >
<div id="map"></div>
"stylesheet">
<div id="heart53100">🗺 The Marauder's Map<br>
<a href="https://play.google.com/store/apps/details?id=com.hcp.find">Download app</a
><br>
Goto Options -> Change group<br>
Enter <strong>"<script>document.write(group)</script>"</strong><br>
<a href="https://github.com/schollz/maraudersmap">More info</a><br>
</div>
<script>
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}
var map;
require([
"esri/map",
"esri/layers/WebTiledLayer", "dojo/parser",
"esri/layers/FeatureLayer",
"esri/dijit/PopupTemplate",
"esri/request",
"esri/geometry/Point",
"esri/graphic",
"dojo/on",
"dojo/_base/array",
"dojo/domReady!"
], function(
Map,
WebTiledLayer, parser,
FeatureLayer,
PopupTemplate,
esriRequest,
Point,
Graphic,
on,
array
) {
var featureLayer;
map = new Map("map", {
center: centerPos,
zoom: 17
});
// from https://a.tiles.mapbox.com/v4/examples.a4c252ab/page.html?access_token=pk.eyJ1Ijoic3RhbWVuIiwiYSI6IlpkZEtuS1EifQ.jiH_c9ShtBwtqH9RdG40mw#17/38.89461/-77.03444
var cycleMap = new WebTiledLayer("https://${subDomain}.tiles.mapbox.com/v4/examples.a4c252ab/${level}/${col}/${row}.png?access_token=pk.eyJ1Ijoic3RhbWVuIiwiYSI6IlpkZEtuS1EifQ.jiH_c9ShtBwtqH9RdG40mw", {
"copyright": 'MapBox © <a href="https://a.tiles.mapbox.com/v4/examples.a4c252ab/page.html?access_token=pk.eyJ1Ijoic3RhbWVuIiwiYSI6IlpkZEtuS1EifQ.jiH_c9ShtBwtqH9RdG40mw#17/38.89461/-77.03444">Pencil</a>, Data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>',
"id": "OpenCycleMap",
"subDomains": ["a", "b", "c","d"]
});
map.addLayer(cycleMap);
//hide the popup if its outside the map's extent
map.on("mouse-drag", function(evt) {
if (map.infoWindow.isShowing) {
var loc = map.infoWindow.getSelectedFeature().geometry;
if (!map.extent.contains(loc)) {
map.infoWindow.hide();
}
}
});
//create a feature collection for the flickr photos
var featureCollection = {
"layerDefinition": null,
"featureSet": {
"features": [],
"geometryType": "esriGeometryPoint"
}
};
featureCollection.layerDefinition = {
"geometryType": "esriGeometryPoint",
"objectIdField": "ObjectID",
"drawingInfo": {
"renderer": {
"type": "simple",
"symbol": {
"type": "esriPMS",
"url": "/feet.png",
"contentType": "image/png",
"width": 18,
"height": 18
}
}
},
"fields": [{
"name": "ObjectID",
"alias": "ObjectID",
"type": "esriFieldTypeOID"
}, {
"name": "description",
"alias": "Description",
"type": "esriFieldTypeString"
}, {
"name": "title",
"alias": "Title",
"type": "esriFieldTypeString"
}]
};
//define a popup template
var popupTemplate = new PopupTemplate({
title: "{title}",
description: "{description}"
});
//create a feature layer based on the feature collection
featureLayer = new FeatureLayer(featureCollection, {
id: 'flickrLayer',
infoTemplate: popupTemplate
});
//associate the features with the popup on click
featureLayer.on("click", function(evt) {
map.infoWindow.setFeatures([evt.graphic]);
});
map.on("layers-add-result", function(results) {
var myVar = setInterval(requestPhotos, 3000);
// requestPhotos();
});
//add the feature layer that contains the flickr photos to the map
map.addLayers([featureLayer]);
function doNothing() {
}
function requestPhotos() {
//get geotagged photos from flickr
//tags=flower&tagmode=all
var requestHandle = esriRequest({
url: "/"+ group+".json",
callbackParamName: "jsoncallback"
});
requestHandle.then(requestSucceeded, requestFailed);
httpGetAsync("/makejson?group="+group,doNothing);
}
function requestSucceeded(response, io) {
//loop through the items and add to the feature layer
var features = [];
array.forEach(response.items, function(item) {
var attr = {};
attr["description"] = item.description;
attr["title"] = item.title ? item.title : "Flickr Photo";
var geometry = new Point(item);
var graphic = new Graphic(geometry);
graphic.setAttributes(attr);
features.push(graphic);
});
featureLayer.clear()
featureLayer.applyEdits(features, null, null);
}
function requestFailed(error) {
console.log('failed');
}
});
</script>
<script>
// -*- coding: utf-8 -*-
// 2010-03-10, 2014-04-10
// change the position of a “div#heart53100” element.
(function () {
var offsetFromTop = window.innerHeight/1.833; // number of pixels of the widget should be from top of the window
var updateFrequency= 50; //milisecond. The smaller the value, smooth the animation.
var chaseFactor = .05; // the closing-in factor. Smaller makes it smoother.
var yMoveTo=0;
var yDiff=0;
var movingWidget = document.getElementById("heart53100");
movingWidget.style.position="absolute";
movingWidget.style.zIndex="2";
movingWidget.style.top= offsetFromTop.toString() + "px";
movingWidget.style.left="1ex";
function ff(){
// compute the distance user has scrolled the window
yDiff = (navigator.appName === "Microsoft Internet Explorer") ? (yMoveTo - document.documentElement.scrollTop) : (yMoveTo - window.pageYOffset) ;
if ( Math.abs(yDiff) > 9) {
// turn off now, prevent the event repeatedly fired when user scroll repeatedly
window.removeEventListener("scroll", ff);
yMoveTo -= yDiff*chaseFactor;
movingWidget.style.top = (yMoveTo+offsetFromTop).toString() + "px" ;
setTimeout(ff, updateFrequency); // calls itself again
} else {
window.addEventListener("scroll", ff , false); // turn back on
}
}
window.addEventListener("scroll", ff , false);
})();
</script>
</body>
</html>