You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
3.2 KiB
88 lines
3.2 KiB
4 years ago
|
{% extends "base.html" %}
|
||
|
{% import 'bootstrap/wtf.html' as wtf %}
|
||
|
|
||
4 years ago
|
{% block head %}
|
||
|
{{ super() }}
|
||
|
<link rel="stylesheet" href="{{ url_for('static', filename='assets/leaflet/leaflet.css') }}" />
|
||
|
<script src="{{ url_for('static', filename='assets/leaflet/leaflet.js') }}"></script>
|
||
|
{% endblock %}
|
||
|
|
||
4 years ago
|
{% block app_content %}
|
||
4 years ago
|
<h1>Player: {{ user.name }}</h1>
|
||
4 years ago
|
<hr>
|
||
|
<div class="row">
|
||
|
<div class="col-md-4 col-sm-6 col-xs-8">
|
||
4 years ago
|
<div class="row">
|
||
|
<form action="" method="post" class="form" role="form">
|
||
|
{{ form.hidden_tag() }}
|
||
4 years ago
|
{% for gameplayer in user.user_games if gameplayer.game == game %}
|
||
4 years ago
|
{{ wtf.form_field(form.role, class='form-control') }}
|
||
|
{% endfor %}
|
||
|
{{ wtf.form_field(form.submit, class='btn btn-primary', value='Update') }}
|
||
|
</form>
|
||
|
</div>
|
||
4 years ago
|
{% if user.auth_hash %}
|
||
4 years ago
|
<div class="row">
|
||
4 years ago
|
<img src="{{ url_for('main.user_qrcode', auth_hash=user.auth_hash) }}" alt="qr_code_failed", width="100%">
|
||
4 years ago
|
</div>
|
||
|
{% endif %}
|
||
4 years ago
|
</div>
|
||
4 years ago
|
<div id="map" style=" height: 600px; border-radius: 10px; " class="col-md-6 col-xs-12"></div>
|
||
4 years ago
|
</div>
|
||
4 years ago
|
{% endblock %}
|
||
|
|
||
|
|
||
|
{% block scripts %}
|
||
|
{{ super() }}
|
||
|
{{ moment.include_moment() }}
|
||
|
<script type="text/javascript", crossorigin="anonymous">
|
||
|
// Leaflet Map
|
||
4 years ago
|
'{% set last_location = user.last_location(game) %}'
|
||
4 years ago
|
var map = L.map( 'map', {
|
||
|
center: ['{{ last_location.latitude or 52.2 }}', '{{ last_location.longitude or 5.3 }}'],
|
||
|
minZoom: 6,
|
||
|
maxZoom: 19,
|
||
|
bounds: [[50.5, 3.25], [54, 7.6]],
|
||
|
zoom: 9
|
||
|
});
|
||
|
L.control.scale().addTo(map);
|
||
|
|
||
|
L.tileLayer( 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts/brtachtergrondkaartpastel/EPSG:3857/{z}/{x}/{y}.png', {
|
||
4 years ago
|
attribution: 'Kaartgegevens © <a href="https://kadaster.nl">Kadaster</a>'
|
||
4 years ago
|
}).addTo( map );
|
||
|
|
||
|
var greenIcon = new L.Icon({
|
||
|
iconUrl: "{{ url_for('static', filename='assets/leaflet/images/marker-icon-2x-green.png') }}",
|
||
|
shadowUrl: "{{ url_for('static', filename='assets/leaflet/images/marker-shadow.png') }}",
|
||
|
iconSize: [25, 41],
|
||
|
iconAnchor: [12, 41],
|
||
|
popupAnchor: [1, -34],
|
||
|
shadowSize: [41, 41]
|
||
|
});
|
||
|
|
||
4 years ago
|
var locations = JSON.parse('{{ json.dumps(user.locations_during_game(game)), cls=location_encoder)|safe }}')
|
||
4 years ago
|
for (var i = 0; i < locations.length; i++){
|
||
|
var playerMarker = L.marker([
|
||
|
locations[i]['latitude'],
|
||
|
locations[i]['longitude']
|
||
|
], {icon: greenIcon}).addTo(map);
|
||
|
var timestamp_utc = moment.utc(locations[i]['timestamp_utc']).toDate()
|
||
|
var timestamp_local = moment(timestamp_utc).local().format('YYYY-MM-DD HH:mm');
|
||
4 years ago
|
playerMarker.bindTooltip(`<b>${locations[i]['username']}</b><br>
|
||
4 years ago
|
${timestamp_local}`).openPopup();
|
||
|
}
|
||
|
|
||
|
var latlngs = [
|
||
|
[[45.51, -122.68],
|
||
|
[37.77, -122.43],
|
||
|
[34.04, -118.2]],
|
||
|
[[40.78, -73.91],
|
||
|
[41.83, -87.62],
|
||
|
[32.76, -96.72]]
|
||
|
];
|
||
|
var polyline = L.polyline(locations.map(l => [l.latitude, l.longitude]), {color: 'red'}).addTo(map);
|
||
|
// zoom the map to the polyline
|
||
|
map.fitBounds(polyline.getBounds());
|
||
|
|
||
|
</script>
|
||
4 years ago
|
{% endblock %}
|