-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
191 lines (162 loc) · 5.16 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
<html>
<head>
<title>Open Historical Map Highlights (OHMH)</title>
<link rel="stylesheet" href="https://api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.css" />
<script src="https://api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.js"></script>
<link rel="stylesheet" href="jquery-ui-1.10.4/css/ui-lightness/jquery-ui-1.10.4.min.css" />
<link rel="stylesheet" href="jQRangeSlider-5.7.0/css/iThing.css" type="text/css" /><!-- for dateRangeSlider -->
<script src="jquery-ui-1.10.4/js/jquery-1.10.2.js"></script>
<script src="jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js"></script>
<script src="jQRangeSlider-5.7.0/jQDateRangeSlider-min.js"></script>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<style type="text/css">
.header {
float: left;
width: 465px;
}
.filters {
float: left;
}
.filters .slider-container {
padding: 5px;
width: 500px;
}
#map {
clear: both;
height: 80%;
}
</style>
<script type="text/javascript">
var map;
var lyrStuff;
function getStuffLocations() {
var data = 'bbox=' + map.getBounds().toBBoxString();
$.ajax({
url: 'highlights.json',
dataType: 'json',
data: data,
success: showLocations
});
}
function showLocations(ajaxresponse) {
lyrStuff.clearLayers();
lyrStuff.setGeoJSON(ajaxresponse);
lyrStuff.eachLayer(function(layer) {
var content = '<h2>' + layer.feature.properties.name + '<\/h2>' +
'<p>Earliest date: ' + layer.feature.properties.earliest_date + '<br \/>' +
'category: ' + layer.feature.properties.category + '<\/p>' +
'<p><a href="http://www.openhistoricalmap.org/#map=' + layer.feature.properties.zoom_recomendation + '/' + layer.feature.geometry.coordinates[1] + '/' + layer.feature.geometry.coordinates[0] + '&layers=H" target="_blank">view on OHM';
layer.bindPopup(content);
});
}
function attachClickEvent(feature, layer)
{
//layer.on('click', visitCam, feature.properties.refCode);
}
function visitCam()
{
//console.log("hello"+ this);
window.location = "selfie.php?cam=" + this;
}
$( document ).ready(function() {
//load map
map = L.mapbox.map('map').setView([50, 0], 2);
//geolocate
//map.locate({setView: true, maxZoom: 19});
//add cams
//var camerasFile = 'getcams.php';
//more base layers
var OpenHistorialLayer = L.tileLayer('http://www.openhistoricalmap.org/ohm_tiles/{z}/{x}/{y}.png', {
attribution: 'Maps from <a href="http://wiki.openstreetmap.org/wiki/OHM">OHM</a>',
});
map.addLayer(OpenHistorialLayer);
//add a layer switcher
var baseMaps = {
"Open Historical Map": OpenHistorialLayer
};
L.control.layers(baseMaps).addTo(map);
var baseJson = {
"type":"FeatureCollection",
"features":[
]
};
lyrStuff = L.mapbox.featureLayer(baseJson, {
//onEachFeature: attachClickEvent
})
.addTo(map);
getStuffLocations();
$("#slider").dateRangeSlider({
bounds: {min: new Date(-4000, 0, 1),
max: new Date(2014, 5, 1)
},
defaultValues: {min: new Date(-3200, 0, 1),
max: new Date(1776, 6, 4)}
});
$("#slider").bind("valuesChanged", function(e, data){
//console.log("Values just changed. min: " + data.values.min + " max: " + data.values.max);
//odd value fixes
var rangeMin = data.values.min.getYear() + 1900;
var rangeMax = data.values.max.getYear() + 1900;
lyrStuff.setFilter(function(f) {
//check if it's in date
if(f.properties['earliest_date'] != undefined) {
if(f.properties['earliest_date'] > (rangeMin) ) {
afterMin = true;
} else {
afterMin = false; //before range
}
} else {
afterMin = true; //assume
}
if(f.properties['latest_date'] != undefined) {
if(f.properties['latest_date'] < (rangeMax) ) {
beforeMax = true;
} else {
beforeMax = false; //before range
}
if(f.properties['earliest_date'] == undefined) {
if(f.properties['latest_date'] < (rangeMin) ) {
afterMin = false; //overwrite our assumption
}
}
} else {
beforeMax = true; //assume
}
if(f.properties['latest_date'] == undefined && f.properties['earliest_date'] != undefined) {
if(f.properties['earliest_date'] > (rangeMax) ) {
beforeMax = false; //overwrite our assumption
}
}
//old style checks
afterStart = (f.properties['earliest_date'] >= (rangeMin) );
beforeEnd = (f.properties['earliest_date'] <= (rangeMax) );
/*
console.log(
f.properties['earliest_date'] + ' to ' + f.properties['latest_date'] + ' for '
+ rangeMin + ' to ' + rangeMax
+ ' afterMin=' + afterMin + ' beforeMax=' + beforeMax
);
*/
//make the changes
return afterMin && beforeMax;
});
});
});
</script>
</head>
<body>
<div class="header">
<h1>Open Historical Map Highlights</h1>
<p>Highlights of data being managed in OpenHistoricalMap.</p>
</div>
<div class="filters">
Show highlights during:
<article class="slider-container">
<div id="slider"></div>
</article>
</div>
<div class="container">
<div id="map"></div>
</div>
</body>
</html>