|
|
@ -2,26 +2,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
{% block main %}
|
|
|
|
{% block main %}
|
|
|
|
<div id="home_content">
|
|
|
|
<div id="home_content">
|
|
|
|
<p id="position"></p>
|
|
|
|
<p id="position"></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="compass">
|
|
|
|
<div class="compass">
|
|
|
|
<div id="arrow" class="arrow"><svg viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path class="st0" d="M13,2.6l6.2,7.5L20,9.5l-7.5-9L5,9.5l0.8,0.6L12,2.6v21.9h1C13,24.5,13,2.6,13,2.6z"/></svg></div>
|
|
|
|
<div id="arrow" class="arrow"><svg viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd"
|
|
|
|
<div id="goal" class="compass-goal"><svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21.94 21.94"><defs><style>.cls-1{fill:#3fb800;opacity:.3;}</style></defs><g id="Layer_1-2"><circle class="cls-1" cx="10.97" cy="10.97" r="10.97"/></g></svg></div>
|
|
|
|
clip-rule="evenodd">
|
|
|
|
|
|
|
|
<path class="st0" d="M13,2.6l6.2,7.5L20,9.5l-7.5-9L5,9.5l0.8,0.6L12,2.6v21.9h1C13,24.5,13,2.6,13,2.6z" /></svg>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="goal" class="compass-goal"><svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21.94 21.94">
|
|
|
|
|
|
|
|
<defs>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
.cls-1 {
|
|
|
|
|
|
|
|
fill: #3fb800;
|
|
|
|
|
|
|
|
opacity: .3;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
</defs>
|
|
|
|
|
|
|
|
<g id="Layer_1-2">
|
|
|
|
|
|
|
|
<circle class="cls-1" cx="10.97" cy="10.97" r="10.97" />
|
|
|
|
|
|
|
|
</g>
|
|
|
|
|
|
|
|
</svg></div>
|
|
|
|
<div class="my-point"></div>
|
|
|
|
<div class="my-point"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- <h1 class="header" id="title">GEO</h1> -->
|
|
|
|
<!-- <h1 class="header" id="title">GEO</h1> -->
|
|
|
|
<div id="button_group">
|
|
|
|
<div id="button_group">
|
|
|
|
<div id="distance_close">(distance to mosquito)</div>
|
|
|
|
<div id="distance_close">(distance to mosquito)</div>
|
|
|
|
<button id="store_location" onclick="store_location()"><img src="/static/img/hangout.png" alt="">add hangout</button>
|
|
|
|
<button id="store_location" onclick="store_location()"><img src="/static/img/hangout.png" alt="">add
|
|
|
|
<button id="store_location_mosquito" onclick="store_location_mosquito()"><img src="/static/img/mosquito.png" alt="">add mosquito</button>
|
|
|
|
hangout</button>
|
|
|
|
|
|
|
|
<button id="store_location_mosquito" onclick="store_location_mosquito()"><img src="/static/img/mosquito.png"
|
|
|
|
|
|
|
|
alt="">add mosquito</button>
|
|
|
|
<button id="add_text" onclick="add_text()"><img src="/static/img/text.png" alt="">add message</button>
|
|
|
|
<button id="add_text" onclick="add_text()"><img src="/static/img/text.png" alt="">add message</button>
|
|
|
|
<button id="add_audio" onclick="add_audio()"><img src="/static/img/audio.png" alt=""> add audio</button>
|
|
|
|
<button id="add_audio" onclick="add_audio()"><img src="/static/img/audio.png" alt=""> add audio</button>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="viewSelector" onchange="changeViewSelect()" >
|
|
|
|
<select id="viewSelector" onchange="changeViewSelect()">
|
|
|
|
<option>Choose view</option>
|
|
|
|
<option>Choose view</option>
|
|
|
|
<option value="all">show all entries</option>
|
|
|
|
<option value="all">show all entries</option>
|
|
|
|
<option value="closest">show closest mosquito</option>
|
|
|
|
<option value="closest">show closest mosquito</option>
|
|
|
@ -33,9 +50,6 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- HEADING DIRECTION https://stackoverflow.com/questions/46033649/heading-javascript-geolocation -->
|
|
|
|
<!-- HEADING DIRECTION https://stackoverflow.com/questions/46033649/heading-javascript-geolocation -->
|
|
|
|
<!-- COMPASS CROSS DEVICE https://stackoverflow.com/questions/16048514/can-i-use-javascript-to-get-the-compass-heading-for-ios-and-android-->
|
|
|
|
<!-- COMPASS CROSS DEVICE https://stackoverflow.com/questions/16048514/can-i-use-javascript-to-get-the-compass-heading-for-ios-and-android-->
|
|
|
|
|
|
|
|
|
|
|
@ -64,18 +78,22 @@
|
|
|
|
var markerArray = [];
|
|
|
|
var markerArray = [];
|
|
|
|
var circleArray = [];
|
|
|
|
var circleArray = [];
|
|
|
|
var mosquitoArray = [];
|
|
|
|
var mosquitoArray = [];
|
|
|
|
var view="closest";
|
|
|
|
var view = "me";
|
|
|
|
var workingCompass = false;
|
|
|
|
var workingCompass = false;
|
|
|
|
var map_view = false;
|
|
|
|
var map_view = false;
|
|
|
|
|
|
|
|
|
|
|
|
function assign_data(data) {
|
|
|
|
function assign_data(data) {
|
|
|
|
locations = data;
|
|
|
|
locations = data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assign_data({{ data_locations|tojson }});
|
|
|
|
assign_data({
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data_locations | tojson
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var map = L.map('map', {
|
|
|
|
var map = L.map('map', {
|
|
|
|
attributionControl:false,
|
|
|
|
attributionControl: false,
|
|
|
|
zoomControl:false,
|
|
|
|
zoomControl: false,
|
|
|
|
zoom: 2000,
|
|
|
|
zoom: 2000,
|
|
|
|
zoomSnap: 0.5,
|
|
|
|
zoomSnap: 0.5,
|
|
|
|
animate: true,
|
|
|
|
animate: true,
|
|
|
@ -86,51 +104,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
var backgroundLayer = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
|
|
var backgroundLayer = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
|
|
maxZoom: 19,
|
|
|
|
maxZoom: 19,
|
|
|
|
zoom:2,
|
|
|
|
zoom: 2,
|
|
|
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
|
|
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function toggle_map() {
|
|
|
|
|
|
|
|
if (map_view) {
|
|
|
|
function toggle_map(){
|
|
|
|
|
|
|
|
if(map_view){
|
|
|
|
|
|
|
|
map.removeLayer(backgroundLayer)
|
|
|
|
map.removeLayer(backgroundLayer)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else{
|
|
|
|
|
|
|
|
map.addLayer(backgroundLayer)
|
|
|
|
map.addLayer(backgroundLayer)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
map_view = !map_view
|
|
|
|
map_view = !map_view
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var myIcon = L.icon({
|
|
|
|
|
|
|
|
iconUrl: '/static/img/me.png',
|
|
|
|
|
|
|
|
iconSize: [30, 30],
|
|
|
|
|
|
|
|
iconAnchor: [15, 15],
|
|
|
|
|
|
|
|
popupAnchor: [-3, -76],
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var myPositionCircle = L.marker([50.505, 30.57], {
|
|
|
|
|
|
|
|
icon: myIcon
|
|
|
|
|
|
|
|
}).addTo(map);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
circleArray.push(myPositionCircle);
|
|
|
|
|
|
|
|
|
|
|
|
locations.forEach(function (item, index) {
|
|
|
|
locations.forEach(function (item, index) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
var icon;
|
|
|
|
var icon;
|
|
|
|
if(item.loc_type=="message"){
|
|
|
|
if (item.loc_type == "message") {
|
|
|
|
icon = L.icon({
|
|
|
|
icon = L.icon({
|
|
|
|
iconUrl: '/static/img/text.png',
|
|
|
|
iconUrl: '/static/img/text.png',
|
|
|
|
iconSize: [50, 50],
|
|
|
|
iconSize: [50, 50],
|
|
|
|
iconAnchor: [25, 25],
|
|
|
|
iconAnchor: [25, 25],
|
|
|
|
popupAnchor: [-3, -76],
|
|
|
|
popupAnchor: [-3, -76],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else if (item.loc_type == "audio") {
|
|
|
|
else if(item.loc_type=="audio"){
|
|
|
|
|
|
|
|
icon = L.icon({
|
|
|
|
icon = L.icon({
|
|
|
|
iconUrl: '/static/img/audio.png',
|
|
|
|
iconUrl: '/static/img/audio.png',
|
|
|
|
iconSize: [50, 50],
|
|
|
|
iconSize: [50, 50],
|
|
|
|
iconAnchor: [25, 25],
|
|
|
|
iconAnchor: [25, 25],
|
|
|
|
popupAnchor: [-3, -76],
|
|
|
|
popupAnchor: [-3, -76],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else if (item.loc_type == "mosquito") {
|
|
|
|
else if(item.loc_type=="mosquito"){
|
|
|
|
|
|
|
|
icon = L.icon({
|
|
|
|
icon = L.icon({
|
|
|
|
iconUrl: '/static/img/mosquito.png',
|
|
|
|
iconUrl: '/static/img/mosquito.png',
|
|
|
|
iconSize: [50, 50],
|
|
|
|
iconSize: [50, 50],
|
|
|
|
iconAnchor: [25, 25],
|
|
|
|
iconAnchor: [25, 25],
|
|
|
|
popupAnchor: [-3, -76],
|
|
|
|
popupAnchor: [-3, -76],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else if (item.loc_type == "hangout") {
|
|
|
|
else if(item.loc_type=="hangout"){
|
|
|
|
|
|
|
|
icon = L.icon({
|
|
|
|
icon = L.icon({
|
|
|
|
iconUrl: '/static/img/hangout.png',
|
|
|
|
iconUrl: '/static/img/hangout.png',
|
|
|
|
iconSize: [50, 50],
|
|
|
|
iconSize: [50, 50],
|
|
|
@ -138,53 +162,35 @@
|
|
|
|
popupAnchor: [-3, -76],
|
|
|
|
popupAnchor: [-3, -76],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var circle = L.marker([item.latitude, item.longitude], {icon: icon}).addTo(map).on("click", e => circleClick(e));
|
|
|
|
var circle = L.marker([item.latitude, item.longitude], {
|
|
|
|
|
|
|
|
icon: icon
|
|
|
|
|
|
|
|
}).addTo(map).on("click", e => circleClick(e));
|
|
|
|
circle.id = item.id;
|
|
|
|
circle.id = item.id;
|
|
|
|
circleArray.push(circle);
|
|
|
|
circleArray.push(circle);
|
|
|
|
|
|
|
|
|
|
|
|
markerArray.push(L.marker([item.latitude, item.longitude]));
|
|
|
|
markerArray.push(L.marker([item.latitude, item.longitude]));
|
|
|
|
|
|
|
|
|
|
|
|
if(item.loc_type=="mosquito") mosquitoArray.push(L.marker([item.latitude, item.longitude]));
|
|
|
|
if (item.loc_type == "mosquito") mosquitoArray.push(L.marker([item.latitude, item.longitude]));
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// var myPositionCircle = L.circle([48.172934, 9.01236], {
|
|
|
|
|
|
|
|
// color: 'red',
|
|
|
|
|
|
|
|
// stroke:false,
|
|
|
|
|
|
|
|
// fillColor: 'red',
|
|
|
|
|
|
|
|
// fillOpacity: 0.5,
|
|
|
|
|
|
|
|
// radius: 10
|
|
|
|
|
|
|
|
// }).addTo(map);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var myIcon = L.icon({
|
|
|
|
|
|
|
|
iconUrl: '/static/img/me.png',
|
|
|
|
|
|
|
|
iconSize: [50, 50],
|
|
|
|
|
|
|
|
iconAnchor: [25, 25],
|
|
|
|
|
|
|
|
popupAnchor: [-3, -76],
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var myPositionCircle = L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
circleArray.push(myPositionCircle);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var x = document.getElementById("position");
|
|
|
|
var x = document.getElementById("position");
|
|
|
|
|
|
|
|
|
|
|
|
let id;
|
|
|
|
let id;
|
|
|
|
let target;
|
|
|
|
let target;
|
|
|
|
let options;
|
|
|
|
let options;
|
|
|
|
|
|
|
|
|
|
|
|
//first: latitude, second: longitude
|
|
|
|
//first: latitude, second: longitude 51.915528423609125, 4.477065873620031
|
|
|
|
target = {
|
|
|
|
target = {
|
|
|
|
latitude : 48.172934,
|
|
|
|
latitude: 51.915528423609125,
|
|
|
|
longitude: 9.01236
|
|
|
|
longitude: 4.477065873620031
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var my_location = {
|
|
|
|
var my_location = {
|
|
|
|
latitude : 0,
|
|
|
|
latitude: 0,
|
|
|
|
longitude: 0
|
|
|
|
longitude: 0
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -193,9 +199,7 @@
|
|
|
|
my_location.longitude = crd.longitude;
|
|
|
|
my_location.longitude = crd.longitude;
|
|
|
|
my_location.latitude = crd.latitude;
|
|
|
|
my_location.latitude = crd.latitude;
|
|
|
|
|
|
|
|
|
|
|
|
if(view == "closest") updateView()
|
|
|
|
updateView()
|
|
|
|
|
|
|
|
|
|
|
|
console.log("updated")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x.innerHTML = "Latitude: " + crd.latitude +
|
|
|
|
x.innerHTML = "Latitude: " + crd.latitude +
|
|
|
|
"<br>Longitude: " + crd.longitude +
|
|
|
|
"<br>Longitude: " + crd.longitude +
|
|
|
@ -216,7 +220,6 @@
|
|
|
|
// id = navigator.geolocation.watchPosition(success, error, options);
|
|
|
|
// id = navigator.geolocation.watchPosition(success, error, options);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options = {
|
|
|
|
options = {
|
|
|
|
enableHighAccuracy: true,
|
|
|
|
enableHighAccuracy: true,
|
|
|
|
timeout: 1000,
|
|
|
|
timeout: 1000,
|
|
|
@ -227,102 +230,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
function distance(lon1, lat1, lon2, lat2) {
|
|
|
|
function distance(lon1, lat1, lon2, lat2) {
|
|
|
|
var R = 6371; // Radius of the earth in km
|
|
|
|
var R = 6371; // Radius of the earth in km
|
|
|
|
var dLat = (lat2-lat1).toRad(); // Javascript functions in radians
|
|
|
|
var dLat = (lat2 - lat1).toRad(); // Javascript functions in radians
|
|
|
|
var dLon = (lon2-lon1).toRad();
|
|
|
|
var dLon = (lon2 - lon1).toRad();
|
|
|
|
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
|
|
|
|
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
|
|
Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
|
|
|
|
Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
|
|
|
|
Math.sin(dLon/2) * Math.sin(dLon/2);
|
|
|
|
Math.sin(dLon / 2) * Math.sin(dLon / 2);
|
|
|
|
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
|
|
|
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
|
|
var d = R * c; // Distance in km
|
|
|
|
var d = R * c; // Distance in km
|
|
|
|
var text;
|
|
|
|
var text;
|
|
|
|
if(d < 1){
|
|
|
|
if (d < 1) {
|
|
|
|
text = Math.round(d * 100) / 100*1000+" m";
|
|
|
|
text = Math.round(d * 100) / 100 * 1000 + " m";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else{
|
|
|
|
text = Math.round(d * 100) / 100 + " km"
|
|
|
|
text = Math.round(d * 100) / 100+" km"
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return text;
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Converts numeric degrees to radians */
|
|
|
|
/** Converts numeric degrees to radians */
|
|
|
|
if (typeof(Number.prototype.toRad) === "undefined") {
|
|
|
|
if (typeof (Number.prototype.toRad) === "undefined") {
|
|
|
|
Number.prototype.toRad = function() {
|
|
|
|
Number.prototype.toRad = function () {
|
|
|
|
return this * Math.PI / 180;
|
|
|
|
return this * Math.PI / 180;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function store_location(){
|
|
|
|
function store_location() {
|
|
|
|
// console.log("storing location");
|
|
|
|
window.location.href = "addhangout/" + my_location.longitude + "/" + my_location.latitude + "/";
|
|
|
|
// console.log(my_location)
|
|
|
|
|
|
|
|
// var xhr = new XMLHttpRequest();
|
|
|
|
|
|
|
|
// xhr.open("POST", "./addlocation", true);
|
|
|
|
|
|
|
|
// xhr.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
|
|
|
|
// xhr.send(JSON.stringify({
|
|
|
|
|
|
|
|
// longitude: my_location.longitude,
|
|
|
|
|
|
|
|
// latitude: my_location.latitude
|
|
|
|
|
|
|
|
// }));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// xhr.onreadystatechange=function(){
|
|
|
|
|
|
|
|
// if (xhr.readyState==4 && xhr.status==200){
|
|
|
|
|
|
|
|
// location.reload();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
window.location.href = "addhangout/"+ my_location.longitude +"/"+my_location.latitude+"/";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function store_location_mosquito(){
|
|
|
|
function store_location_mosquito() {
|
|
|
|
// console.log("storing location");
|
|
|
|
window.location.href = "addmosquito/" + my_location.longitude + "/" + my_location.latitude + "/";
|
|
|
|
// console.log(my_location)
|
|
|
|
|
|
|
|
// var xhr = new XMLHttpRequest();
|
|
|
|
|
|
|
|
// xhr.open("POST", "./addlocationmosquito", true);
|
|
|
|
|
|
|
|
// xhr.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
|
|
|
|
// xhr.send(JSON.stringify({
|
|
|
|
|
|
|
|
// longitude: my_location.longitude,
|
|
|
|
|
|
|
|
// latitude: my_location.latitude
|
|
|
|
|
|
|
|
// }));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// xhr.onreadystatechange=function(){
|
|
|
|
|
|
|
|
// if (xhr.readyState==4 && xhr.status==200){
|
|
|
|
|
|
|
|
// location.reload();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.location.href = "addmosquito/"+my_location.longitude +"/"+my_location.latitude+"/";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function add_text(){
|
|
|
|
function add_text() {
|
|
|
|
window.location.href = "addtext/"+my_location.longitude +"/"+my_location.latitude+"/";
|
|
|
|
window.location.href = "addtext/" + my_location.longitude + "/" + my_location.latitude + "/";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function add_audio(){
|
|
|
|
function add_audio() {
|
|
|
|
window.location.href = "addaudio/"+my_location.longitude +"/"+my_location.latitude+"/";
|
|
|
|
window.location.href = "addaudio/" + my_location.longitude + "/" + my_location.latitude + "/";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function updateView(){
|
|
|
|
function updateView() {
|
|
|
|
//update position on map
|
|
|
|
//update position on map
|
|
|
|
// map.setView([my_location.latitude, my_location.longitude], zoom_level);
|
|
|
|
// map.setView([my_location.latitude, my_location.longitude], zoom_level);
|
|
|
|
myPositionCircle.setLatLng([my_location.latitude, my_location.longitude]);
|
|
|
|
myPositionCircle.setLatLng([my_location.latitude, my_location.longitude]);
|
|
|
|
if(view == "all"){
|
|
|
|
if (view == "all") {
|
|
|
|
var group = new L.featureGroup(circleArray);
|
|
|
|
var group = new L.featureGroup(circleArray);
|
|
|
|
map.fitBounds(group.getBounds().pad(0.4));
|
|
|
|
map.fitBounds(group.getBounds().pad(0.4));
|
|
|
|
}
|
|
|
|
} else if (view == "closest") {
|
|
|
|
else if(view == "closest"){
|
|
|
|
|
|
|
|
var closest = L.GeometryUtil.closestLayer(map, mosquitoArray, myPositionCircle.getLatLng());
|
|
|
|
var closest = L.GeometryUtil.closestLayer(map, mosquitoArray, myPositionCircle.getLatLng());
|
|
|
|
// L.polyline([closest.layer.getLatLng(), myPositionCircle.getLatLng()], {
|
|
|
|
document.getElementById("distance_close").innerHTML = "closest mosquito: " + distance(closest.layer.getLatLng()
|
|
|
|
// color: 'black',
|
|
|
|
.lng, closest.layer.getLatLng().lat, myPositionCircle.getLatLng().lng, myPositionCircle.getLatLng().lat)
|
|
|
|
// weight: 1,
|
|
|
|
|
|
|
|
// }).addTo(map)
|
|
|
|
|
|
|
|
document.getElementById("distance_close").innerHTML = "closest mosquito: " + distance(closest.layer.getLatLng().lat,closest.layer.getLatLng().lng,myPositionCircle.getLatLng().lat, myPositionCircle.getLatLng().lng)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var group = new L.featureGroup([closest.layer, myPositionCircle]);
|
|
|
|
var group = new L.featureGroup([closest.layer, myPositionCircle]);
|
|
|
|
map.fitBounds(group.getBounds().pad(0.4));
|
|
|
|
map.fitBounds(group.getBounds().pad(0.4));
|
|
|
|
}
|
|
|
|
} else if (view == "me") {
|
|
|
|
else if(view == "me"){
|
|
|
|
|
|
|
|
map.setView([my_location.latitude, my_location.longitude], zoom_level);
|
|
|
|
map.setView([my_location.latitude, my_location.longitude], zoom_level);
|
|
|
|
}
|
|
|
|
} else if (view == "free") {
|
|
|
|
else if(view == "free"){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -333,25 +298,25 @@
|
|
|
|
updateView();
|
|
|
|
updateView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function circleClick(e){
|
|
|
|
function circleClick(e) {
|
|
|
|
var id = e.target.id
|
|
|
|
var id = e.target.id
|
|
|
|
var divsToHide = document.getElementsByClassName("row"); //divsToHide is an array
|
|
|
|
var divsToHide = document.getElementsByClassName("row"); //divsToHide is an array
|
|
|
|
for(var i = 0; i < divsToHide.length; i++){
|
|
|
|
for (var i = 0; i < divsToHide.length; i++) {
|
|
|
|
divsToHide[i].style.display = "none"; // depending on what you're doing
|
|
|
|
divsToHide[i].style.display = "none"; // depending on what you're doing
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.getElementById(id).style.display = "block";
|
|
|
|
document.getElementById(id).style.display = "block";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function closeLocation(){
|
|
|
|
function closeLocation() {
|
|
|
|
var divsToHide = document.getElementsByClassName("row"); //divsToHide is an array
|
|
|
|
var divsToHide = document.getElementsByClassName("row"); //divsToHide is an array
|
|
|
|
for(var i = 0; i < divsToHide.length; i++){
|
|
|
|
for (var i = 0; i < divsToHide.length; i++) {
|
|
|
|
divsToHide[i].style.display = "none"; // depending on what you're doing
|
|
|
|
divsToHide[i].style.display = "none"; // depending on what you're doing
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('resize', function(event) {
|
|
|
|
window.addEventListener('resize', function (event) {
|
|
|
|
updateView()
|
|
|
|
updateView()
|
|
|
|
}, true);
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
|
|
|
|
// COMPASS
|
|
|
|
// COMPASS
|
|
|
|
const compassCircle = document.querySelector(".arrow");
|
|
|
|
const compassCircle = document.querySelector(".arrow");
|
|
|
@ -389,7 +354,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
function handler(e) {
|
|
|
|
function handler(e) {
|
|
|
|
workingCompass = true;
|
|
|
|
workingCompass = true;
|
|
|
|
if(workingCompass){
|
|
|
|
if (workingCompass) {
|
|
|
|
document.getElementById("arrow").style.display = "block";
|
|
|
|
document.getElementById("arrow").style.display = "block";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
compass = e.webkitCompassHeading || Math.abs(e.alpha - 360);
|
|
|
|
compass = e.webkitCompassHeading || Math.abs(e.alpha - 360);
|
|
|
@ -399,7 +364,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
function locationHandler(position) {
|
|
|
|
function locationHandler(position) {
|
|
|
|
|
|
|
|
|
|
|
|
const { latitude, longitude } = position.coords;
|
|
|
|
const {
|
|
|
|
|
|
|
|
latitude,
|
|
|
|
|
|
|
|
longitude
|
|
|
|
|
|
|
|
} = position.coords;
|
|
|
|
pointDegree = calcDegreeToPoint(latitude, longitude);
|
|
|
|
pointDegree = calcDegreeToPoint(latitude, longitude);
|
|
|
|
|
|
|
|
|
|
|
|
if (pointDegree < 0) {
|
|
|
|
if (pointDegree < 0) {
|
|
|
@ -410,12 +378,12 @@
|
|
|
|
function calcDegreeToPoint(latitude, longitude) {
|
|
|
|
function calcDegreeToPoint(latitude, longitude) {
|
|
|
|
// Qibla geolocation
|
|
|
|
// Qibla geolocation
|
|
|
|
var closest = L.GeometryUtil.closestLayer(map, mosquitoArray, myPositionCircle.getLatLng());
|
|
|
|
var closest = L.GeometryUtil.closestLayer(map, mosquitoArray, myPositionCircle.getLatLng());
|
|
|
|
if(workingCompass == true){
|
|
|
|
if (workingCompass == true) {
|
|
|
|
if(parseFloat(distance(closest.layer.getLatLng().lat,closest.layer.getLatLng().lng,myPositionCircle.getLatLng().lat, myPositionCircle.getLatLng().lng).split(" "))<20){
|
|
|
|
if (parseFloat(distance(closest.layer.getLatLng().lat, closest.layer.getLatLng().lng, myPositionCircle.getLatLng()
|
|
|
|
|
|
|
|
.lat, myPositionCircle.getLatLng().lng).split(" ")) < 20) {
|
|
|
|
document.getElementById("arrow").style.display = "none";
|
|
|
|
document.getElementById("arrow").style.display = "none";
|
|
|
|
document.getElementById("goal").style.display = "block";
|
|
|
|
document.getElementById("goal").style.display = "block";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else{
|
|
|
|
|
|
|
|
document.getElementById("arrow").style.display = "block";
|
|
|
|
document.getElementById("arrow").style.display = "block";
|
|
|
|
document.getElementById("goal").style.display = "none";
|
|
|
|
document.getElementById("goal").style.display = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -442,8 +410,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
init();
|
|
|
|
init();
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{% endblock js %}
|
|
|
|
{% endblock js %}
|