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
5 years ago
|
{% extends "base.html" %}
|
||
|
{% import 'bootstrap/wtf.html' as wtf %}
|
||
|
|
||
5 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 %}
|
||
|
|
||
5 years ago
|
{% block app_content %}
|
||
5 years ago
|
<h1>Player: {{ user.name }}</h1>
|
||
5 years ago
|
<hr>
|
||
|
<div class="row">
|
||
|
<div class="col-md-4 col-sm-6 col-xs-8">
|
||
5 years ago
|
<div class="row">
|
||
|
<form action="" method="post" class="form" role="form">
|
||
|
{{ form.hidden_tag() }}
|
||
5 years ago
|
{% for gameplayer in user.user_games if gameplayer.game == game %}
|
||
5 years ago
|
{{ wtf.form_field(form.role, class='form-control') }}
|
||
|
{% endfor %}
|
||
|
{{ wtf.form_field(form.submit, class='btn btn-primary', value='Update') }}
|
||
|
</form>
|
||
|
</div>
|
||
5 years ago
|
{% if user.auth_hash %}
|
||
5 years ago
|
<div class="row">
|
||
5 years ago
|
<img src="{{ url_for('main.user_qrcode', auth_hash=user.auth_hash) }}" alt="qr_code_failed", width="100%">
|
||
5 years ago
|
</div>
|
||
|
{% endif %}
|
||
5 years ago
|
</div>
|
||
5 years ago
|
<div id="map" style=" height: 600px; border-radius: 10px; " class="col-md-6 col-xs-12"></div>
|
||
5 years ago
|
</div>
|
||
5 years ago
|
{% endblock %}
|
||
|
|
||
|
|
||
|
{% block scripts %}
|
||
|
{{ super() }}
|
||
|
{{ moment.include_moment() }}
|
||
|
<script type="text/javascript", crossorigin="anonymous">
|
||
|
// Leaflet Map
|
||
5 years ago
|
'{% set last_location = user.last_location(game) %}'
|
||
5 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', {
|
||
5 years ago
|
attribution: 'Kaartgegevens © <a href="https://kadaster.nl">Kadaster</a>'
|
||
5 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]
|
||
|
});
|
||
|
|
||
5 years ago
|
var locations = JSON.parse('{{ json.dumps(user.locations_during_game(game)), cls=location_encoder)|safe }}')
|
||
5 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');
|
||
5 years ago
|
playerMarker.bindTooltip(`<b>${locations[i]['username']}</b><br>
|
||
5 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>
|
||
5 years ago
|
{% endblock %}
|