Inital commit
This commit is contained in:
commit
bedd69436b
175 files changed
+9965
No files matched your search
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* LeafletSearch 1.0.1
|
||||
* (c) 2021 Sjaak Priester, Amsterdam
|
||||
* MIT License
|
||||
* https://github.com/sjaakp/leaflet-search
|
||||
* https://sjaakpriester.nl
|
||||
*/
|
||||
!function(){"use strict";!function(t){if(!t||"undefined"==typeof window)return;const e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML=t,document.head.appendChild(e)}(".geo-search svg{display:block;width:100%;height:100%;position:relative}.geo-search input{transition:width .4s;width:0;padding:2px 0;border:solid #888;border-width:1px 0;outline:0}.geo-search.open input{width:15em;padding:2px 2px;border-width:1px;border-top-left-radius:4px;border-bottom-left-radius:4px}.geo-search button{background-color:#fff;border:none;border:1px solid #ccc;width:26px;height:26px;line-height:26px;display:block;text-align:center;text-decoration:none;color:#000;background-position:50% 50%;background-repeat:no-repeat;overflow:hidden;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-left-radius:4px;border-bottom-right-radius:4px;display:block}.geo-search button:hover{background-color:#ddd}"),L.geo={Geocoder:L.Class.extend({initialize:function(t,e){this._map=t,L.setOptions(this,e)},constructUrl:function(t,e){void 0===e&&(e={});var n=Object.assign({},this.options,e),o=new URL(t);for(var r in n)o.searchParams.set(r,n[r]);return o},fetchJson:function(t){return fetch(t.href).then((function(t){return t.json()}))},placeMarker:function(t,e,n){this._map.placeMarker(t,e,n)},fire:function(t){this._map.fire(t)},suggest:function(t,e){},lookup:function(t){}})},L.geo.Nominatim=L.geo.Geocoder.extend({url:"https://nominatim.openstreetmap.org/",mark:function(t){var e=L.latLng(t.lat,t.lon),n=t.boundingbox,o=L.latLngBounds([n[0],n[2]],[n[1],n[3]]);this.placeMarker(e,o,t)},search:function(t){var e=this.constructUrl(this.url+"search",{format:"json",q:t});return this.fetchJson(e)},suggest:function(t,e){var n=this;this.search(t).then((function(t){e.innerHTML=t.reduce((function(t,e){return t+'<option data-id="'+e.osm_type.charAt(0).toUpperCase()+e.osm_id+'">'+e.display_name+"</option>"}),"")})).catch((function(t){return n.fire(t)}))},lookup:function(t){var e=this,n=this.constructUrl(this.url+"reverse",{format:"json",osm_type:t.charAt(0),osm_id:t.slice(1)});this.fetchJson(n).then((function(t){return e.mark(t)})).catch((function(t){return e.fire(t)}))},geocode:function(t){var e=this;this.search(t).then((function(t){if(t.length<1)throw"notfound";return t[0]})).then((function(t){return e.mark(t)})).catch((function(t){return e.fire(t)}))}}),L.geo.GeoNames=L.geo.Geocoder.extend({url:"http://api.geonames.org/search",fetchGeonames:function(t){return this.fetchJson(t).then((function(t){var e=t.geonames;if(!e||e.length<1)throw"notfound";return e}))},mark:function(t){var e=L.latLng(t.lat,t.lng),n=t.bbox,o=L.latLngBounds([n.north,n.west],[n.south,n.east]);this.placeMarker(e,o,t)},suggest:function(t,e){var n=this,o=this.constructUrl(this.url,{q:t,type:"json",style:"short"});this.fetchGeonames(o).then((function(t){e.innerHTML=t.reduce((function(t,e){return t+'<option data-id="'+e.geonameId+'">'+e.name+" "+e.countryCode+"</option>"}),"")})).catch((function(t){return n.fire(t)}))},lookup:function(t){var e=this,n=this.constructUrl("http://api.geonames.org/getJSON",{geonameId:t});this.fetchJson(n).then((function(t){return e.mark(t)})).catch((function(t){return e.fire(t)}))},geocode:function(t){var e=this,n=this.constructUrl(this.url,{q:t,inclBbox:!0});this.fetchGeonames(n).then((function(t){return t.shift()})).then((function(t){return e.mark(t)})).catch((function(t){return e.fire(t)}))}}),L.geo.Here=L.geo.Geocoder.extend({mark:function(t){var e=t.displayPosition,n=L.latLng(e.latitude,e.longitude),o=t.mapView,r=o.topLeft,i=o.bottomRight,s=L.latLngBounds([r.latitude,i.longitude],[i.latitude,r.longitude]);this.placeMarker(n,s,t)},fetchData:function(t){var e=this;t.jsonattributes=1;var n=this.constructUrl("https://geocoder.ls.hereapi.com/6.2/geocode.json",t);this.fetchJson(n).then((function(t){return t.response.view.shift().result.shift()})).then((function(t){return e.mark(t.location)})).catch((function(t){return e.fire(t)}))},suggest:function(t,e){var n=this,o=this.constructUrl("https://autocomplete.geocoder.ls.hereapi.com/6.2/suggest.json",{query:t});this.fetchJson(o).then((function(t){return t.suggestions})).then((function(t){e.innerHTML=t.reduce((function(t,e){return t+'<option data-id="'+e.locationId+'">'+e.label+"</option>"}),"")})).catch((function(t){return n.fire(t)}))},lookup:function(t){this.fetchData({locationid:t})},geocode:function(t){this.fetchData({searchtext:t})}}),L.geo.TomTom=L.geo.Geocoder.extend({url:"https://api.tomtom.com/search/2/geocode/",suggestions:[],datalist:null,mark:function(t){var e=t.position,n=L.latLng(e.lat,e.lon),o=t.viewport,r=o.topLeftPoint,i=o.btmRightPoint,s=L.latLngBounds([r.lat,i.lon],[i.lat,r.lon]);this.placeMarker(n,s,t)},fetchResults:function(t,e){void 0===e&&(e={});var n=encodeURIComponent(t),o=this.constructUrl(""+this.url+n+".json",e);return this.fetchJson(o).then((function(t){if(t.summary.numResults<1)throw"notfound";return t.results}))},suggest:function(t,e){var n=this;thiLine truncated
|
||||
//# sourceMappingURL=leaflet-search.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"leaflet-search.js","sources":["../src/geo.js","../src/providers/nominatim.js","../src/providers/geonames.js","../src/providers/here.js","../src/providers/tomtom.js","../src/providers/kadaster.js","../node_modules/lodash.debounce/index.js","../src/index.js"],"sourcesContent":["/**\r\n * sjaakp/leaflet-search\r\n * ----------\r\n * Search Control for Leaflet\r\n * Version 1.0.0\r\n * Copyright (c) 2020\r\n * Sjaak Priester, Amsterdam\r\n * MIT License\r\n * https://github.com/sjaakp/leaflet-search\r\n * https://sjaakpriester.nl\r\n */\r\n\r\nL.geo = {\r\n Geocoder: L.Class.extend({\r\n initialize: function (map, options) {\r\n this._map = map;\r\n L.setOptions(this, options);\r\n },\r\n\r\n constructUrl(text, options = {}) {\r\n const opts = Object.assign({}, this.options, options),\r\n url = new URL(text);\r\n for (const k in opts) {\r\n url.searchParams.set(k, opts[k]);\r\n }\r\n return url;\r\n },\r\n\r\n fetchJson(url) {\r\n return fetch(url.href)\r\n .then(response => response.json())\r\n },\r\n\r\n placeMarker(latlng, bbox, place) {\r\n this._map.placeMarker(latlng, bbox, place);\r\n },\r\n\r\n fire(err) {\r\n this._map.fire(err);\r\n },\r\n\r\n suggest(address, datalist) {\r\n },\r\n\r\n lookup(id) {\r\n }\r\n })\r\n};\r\n","\r\n/**\r\n * sjaakp/leaflet-search\r\n * ----------\r\n * Search Control for Leaflet\r\n * Version 1.0.0\r\n * Copyright (c) 2020\r\n * Sjaak Priester, Amsterdam\r\n * MIT License\r\n * https://github.com/sjaakp/leaflet-search\r\n * https://sjaakpriester.nl\r\n */\r\n\r\n/**\r\n * @link https://nominatim.org/release-docs/develop/api/Search/\r\n */\r\nL.geo.Nominatim = L.geo.Geocoder.extend({\r\n url: 'https://nominatim.openstreetmap.org/',\r\n\r\n mark(place) {\r\n const latlng = L.latLng(place.lat, place.lon),\r\n bb = place.boundingbox,\r\n bbox = L.latLngBounds([bb[0], bb[2]], [bb[1], bb[3]]);\r\n this.placeMarker(latlng, bbox, place);\r\n },\r\n\r\n search(address) {\r\n const url = this.constructUrl(this.url + 'search', { format: 'json', q: address });\r\n return this.fetchJson(url)\r\n },\r\n\r\n suggest(address, datalist) {\r\n // const url = this.constructUrl(this.url + 'search', { format: 'json', q: address });\r\n this.search(address)\r\n .then(json => {\r\n // console.log(json);\r\n datalist.innerHTML = json.reduce((a, v) => a + `<option data-id=\"${v.osm_type.charAt(0).toUpperCase()}${v.osm_id}\">${v.display_name}</option>`, '');\r\n })\r\n .catch(error => this.fire(error));\r\n },\r\n\r\n lookup(id) {\r\n const url = this.constructUrl(this.url + 'reverse', {\r\n format: 'json',\r\n osm_type: id.charAt(0),\r\n osm_id: id.slice(1)\r\n });\r\n this.fetchJson(url)\r\n .then(json => this.mark(json))\r\n .catch(error => this.fire(error));\r\n },\r\n\r\n geocode(address) {\r\n // fetch('//nominatim.openstreetmap.org/search?format=json&q=' + encodeURIComponent(address))\r\n // .then(response => response.json())\r\n this.search(address)\r\n .then(json => {\r\n if (json.length < 1) throw('notfound');\r\n return json[0];\r\n })\r\n .then(place => this.mark(place))\r\n .catch(error => this.fire(error));\r\n }\r\n});\r\n","/**\r\n * sjaakp/leaflet-search\r\n * ----------\r\n * Search Control for Leaflet\r\n * Version 1.0.0\r\n * Copyright (c) 2020\r\n * Sjaak Priester, Amsterdam\r\n * MIT License\r\n * https://github.com/sjaakp/leaflet-search\r\n * https://sjaakpriester.nl\r\n */\r\n\r\n/**\r\n * Topological names only; no streets\r\n * @link http://www.geonames.org/export/geonames-search.html\r\n */\r\nL.geo.GeoNames = L.geo.Geocoder.extend({\r\n url: 'http://api.geonames.org/search', // no https!\r\n\r\n fetchGeonames(url) {\r\n return this.fetchJson(url)\r\n .then(json => {\r\n const geonames = json.geonames;\r\n if (! geonames || geonames.length < 1) throw 'notfound';\r\n return geonames;\r\n })\r\n },\r\n\r\n mark(place) {\r\n const latlng = L.latLng(place.lat, place.lng),\r\n bb = place.bbox,\r\n bbox = L.latLngBounds([bb.north, bb.west], [bb.south, bb.east]);\r\n this.placeMarker(latlng, bbox, place);\r\n },\r\n\r\n suggest(address, datalist) {\r\n const url = this.constructUrl(this.url, { q: address, type: 'json', style: 'short' });\r\n\r\n this.fetchGeonames(url)\r\n .then(geonames => {\r\n Line truncated
|
||||
@@ -0,0 +1,89 @@
|
||||
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
|
||||
/*==================================================================
|
||||
[ Focus input ]*/
|
||||
$('.input100').each(function(){
|
||||
$(this).on('blur', function(){
|
||||
if($(this).val().trim() != "") {
|
||||
$(this).addClass('has-val');
|
||||
}
|
||||
else {
|
||||
$(this).removeClass('has-val');
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
/*==================================================================
|
||||
[ Validate ]*/
|
||||
var input = $('.validate-input .input100');
|
||||
|
||||
$('.validate-form').on('submit',function(){
|
||||
var check = true;
|
||||
|
||||
for(var i=0; i<input.length; i++) {
|
||||
if(validate(input[i]) == false){
|
||||
showValidate(input[i]);
|
||||
check=false;
|
||||
}
|
||||
}
|
||||
|
||||
return check;
|
||||
});
|
||||
|
||||
|
||||
$('.validate-form .input100').each(function(){
|
||||
$(this).focus(function(){
|
||||
hideValidate(this);
|
||||
});
|
||||
});
|
||||
|
||||
function validate (input) {
|
||||
if($(input).attr('type') == 'email' || $(input).attr('name') == 'email') {
|
||||
if($(input).val().trim().match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{1,5}|[0-9]{1,3})(\]?)$/) == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($(input).val().trim() == ''){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showValidate(input) {
|
||||
var thisAlert = $(input).parent();
|
||||
|
||||
$(thisAlert).addClass('alert-validate');
|
||||
}
|
||||
|
||||
function hideValidate(input) {
|
||||
var thisAlert = $(input).parent();
|
||||
|
||||
$(thisAlert).removeClass('alert-validate');
|
||||
}
|
||||
|
||||
/*==================================================================
|
||||
[ Show pass ]*/
|
||||
var showPass = 0;
|
||||
$('.btn-show-pass').on('click', function(){
|
||||
if(showPass == 0) {
|
||||
$(this).next('input').attr('type','text');
|
||||
$(this).find('i').removeClass('zmdi-eye');
|
||||
$(this).find('i').addClass('zmdi-eye-off');
|
||||
showPass = 1;
|
||||
}
|
||||
else {
|
||||
$(this).next('input').attr('type','password');
|
||||
$(this).find('i').addClass('zmdi-eye');
|
||||
$(this).find('i').removeClass('zmdi-eye-off');
|
||||
showPass = 0;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,589 @@
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
let retryConnection = false;
|
||||
|
||||
var markers = L.markerClusterGroup({
|
||||
chunkedLoading: true,
|
||||
removeOutsideVisibleBounds: true,
|
||||
});
|
||||
|
||||
// Prepare everything we need for the map
|
||||
let theMarker = L.Marker.extend({
|
||||
options: {
|
||||
id: "-1",
|
||||
},
|
||||
});
|
||||
// Icons
|
||||
const defaultIcon = L.icon({
|
||||
iconUrl: "/img/marker-icon.png",
|
||||
shadowUrl: "",
|
||||
iconSize: [25, 41], // size of the icon
|
||||
shadowSize: [41, 41], // size of the shadow
|
||||
iconAnchor: [12, 41], // point of the icon which will correspond to marker's location
|
||||
popupAnchor: [1, -34], // point from which the popup should open relative to the iconAnchor
|
||||
});
|
||||
|
||||
const signalIcon = L.icon({
|
||||
iconUrl: "/img/signal.png",
|
||||
shadowUrl: "",
|
||||
|
||||
iconSize: [30, 30], // size of the icon
|
||||
shadowSize: [0, 0], // size of the shadow
|
||||
iconAnchor: [15, 15], // point of the icon which will correspond to marker's location
|
||||
shadowAnchor: [0, 0], // the same for the shadow
|
||||
popupAnchor: [0, 0], // point from which the popup should open relative to the iconAnchor
|
||||
});
|
||||
|
||||
const temperatureIcon = L.icon({
|
||||
iconUrl: "/img/temperature.png",
|
||||
shadowUrl: "",
|
||||
|
||||
iconSize: [30, 30], // size of the icon
|
||||
shadowSize: [0, 0], // size of the shadow
|
||||
iconAnchor: [15, 15], // point of the icon which will correspond to marker's location
|
||||
shadowAnchor: [0, 0], // the same for the shadow
|
||||
popupAnchor: [0, 0], // point from which the popup should open relative to the iconAnchor
|
||||
});
|
||||
|
||||
const cctvIcon = L.icon({
|
||||
iconUrl: "/img/cctv.png",
|
||||
shadowUrl: "",
|
||||
|
||||
iconSize: [30, 30], // size of the icon
|
||||
shadowSize: [0, 0], // size of the shadow
|
||||
iconAnchor: [15, 15], // point of the icon which will correspond to marker's location
|
||||
shadowAnchor: [0, 0], // the same for the shadow
|
||||
popupAnchor: [0, 0], // point from which the popup should open relative to the iconAnchor
|
||||
});
|
||||
|
||||
const wifiIcon = L.icon({
|
||||
iconUrl: "/img/wifi.png",
|
||||
shadowUrl: "",
|
||||
|
||||
iconSize: [30, 30], // size of the icon
|
||||
shadowSize: [0, 0], // size of the shadow
|
||||
iconAnchor: [15, 15], // point of the icon which will correspond to marker's location
|
||||
shadowAnchor: [0, 0], // the same for the shadow
|
||||
popupAnchor: [0, 0], // point from which the popup should open relative to the iconAnchor
|
||||
});
|
||||
|
||||
function showPosition(position) {
|
||||
mymap.setView(
|
||||
new L.LatLng(position.coords.latitude, position.coords.longitude),
|
||||
10
|
||||
);
|
||||
}
|
||||
// Share a point
|
||||
function sharePOI(id) {
|
||||
const url = "https://pointsight.project-name-here.de/#" + id;
|
||||
sidebar.prevContent = sidebar._contentContainer.innerHTML;
|
||||
navigator.clipboard.writeText(url);
|
||||
makeToastNotification(
|
||||
"Copy successful",
|
||||
"The link to this point has been copied to your clipboard"
|
||||
);
|
||||
}
|
||||
|
||||
function prepareSidebar(point_id, panTo = false) {
|
||||
const rawData = httpGet(
|
||||
"/api/retrieve?uid=" +
|
||||
point_id +
|
||||
"&key=b03f8aaf-1f32-4d9e-914a-9a50f904833d"
|
||||
);
|
||||
if (rawData.length > 0 && !rawData.includes("502 Bad Gateway")) {
|
||||
retryConnection = false;
|
||||
try {
|
||||
toggleModal("popup-modal-no-conn", false);
|
||||
retryConnection = false;
|
||||
} catch (error) {
|
||||
error;
|
||||
}
|
||||
const moreData = JSON.parse(rawData)[0][0];
|
||||
// Inject toolbar
|
||||
let inspector =
|
||||
'<i class="fas fa-flag reportBtn" style="padding: 4px;" onclick="reportPOI(\'' +
|
||||
point_id +
|
||||
"')\"></i>";
|
||||
inspector +=
|
||||
'<i class="fas fa-share-alt reportBtn" style="padding: 4px;" onclick="sharePOI(\'' +
|
||||
point_id +
|
||||
"')\"></i>";
|
||||
console.warn(moreData);
|
||||
if (moreData.type == "webcam-iframe") {
|
||||
// Prepare the template
|
||||
inspector += httpGet("/templates/inspectorContentIframe.html");
|
||||
inspector = inspector.replaceAll("#TITLE", moreData.titel);
|
||||
inspector = inspector.replaceAll("#URL", moreData.url);
|
||||
inspector = inspector.replaceAll("#URL", moreData.url);
|
||||
} else if (moreData.type == "webcam-image") {
|
||||
// Prepare the template
|
||||
inspector += httpGet("/templates/inspectorContentImage.html");
|
||||
inspector = inspector.replaceAll("#TITLE", moreData.titel);
|
||||
inspector = inspector.replaceAll("#URL", moreData.url);
|
||||
} else if (moreData.type == "iframe") {
|
||||
// Prepare the template
|
||||
inspector += httpGet("/templates/inspectorContentIframe.html");
|
||||
inspector = inspector.replaceAll("#TITLE", moreData.titel);
|
||||
inspector = inspector.replaceAll("#URL", moreData.url);
|
||||
inspector = inspector.replaceAll("#URL", moreData.url);
|
||||
} else if (moreData.type == "request-info") {
|
||||
// Prepare the template
|
||||
inspector += httpGet("/templates/inspectorGeneral.html");
|
||||
inspector = inspector.replaceAll("#TITLE", moreData.object.titel);
|
||||
inspector = inspector.replaceAll("#description", httpGet(moreData.url));
|
||||
} else {
|
||||
inspector += httpGet("/templates/inspectorGeneral.html");
|
||||
inspector = inspector.replaceAll("#TITLE", moreData.titel);
|
||||
inspector = inspector.replaceAll("#description", moreData.description);
|
||||
}
|
||||
// document.getElementById("inspector").innerHTML = inspector;
|
||||
|
||||
sidebar.setContent(inspector);
|
||||
sidebar.show();
|
||||
if (panTo) {
|
||||
mymap.panTo([moreData.location.x, moreData.location.y]);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
if (!retryConnection) {
|
||||
toggleModal("popup-modal-no-conn", true);
|
||||
}
|
||||
|
||||
retryConnection = true;
|
||||
} catch (error) {
|
||||
error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handles click actions for markers
|
||||
function onClick(e) {
|
||||
prepareSidebar(this.options.object.uid);
|
||||
}
|
||||
|
||||
const form = document.getElementById("reportForm");
|
||||
form.addEventListener("submit", (event) => {
|
||||
// submit event detected
|
||||
event.preventDefault();
|
||||
console.log("Report done by users");
|
||||
// Change the UI
|
||||
document.getElementById("reportBtnText").style.display = "none";
|
||||
document.getElementById("loadingSpinner").style.display = "block";
|
||||
document.getElementById("submitBtn").disabled = true;
|
||||
// Get all values
|
||||
const formy = new FormData(form);
|
||||
const reason = formy.get("reason");
|
||||
const email = formy.get("email");
|
||||
const pointId = document.getElementById("pointId").innerHTML;
|
||||
const baseUrl =
|
||||
"/api/internal/report?key=b03f8aaf-1f32-4d9e-914a-9a50f904833d&";
|
||||
let reqUrl =
|
||||
baseUrl + "reason=" + reason + "&mail=" + email + "&point_id=" + pointId;
|
||||
const response = httpGet(reqUrl);
|
||||
const reponseParsed = JSON.parse(response);
|
||||
if (reponseParsed.status == "success") {
|
||||
setTimeout(() => {
|
||||
document.getElementById("loadingDone").style.display = "block";
|
||||
document.getElementById("loadingSpinner").style.display = "none";
|
||||
}, 1000);
|
||||
setTimeout(() => {
|
||||
document.getElementById("reportBtnText").style.display = "block";
|
||||
document.getElementById("loadingSpinner").style.display = "none";
|
||||
document.getElementById("submitBtn").disabled = false;
|
||||
document.getElementById("loadingDone").style.display = "none";
|
||||
toggleModal("report-modal", false);
|
||||
form.reset();
|
||||
makeToastNotification("Report successful", "Thank you for your report.");
|
||||
}, 2000);
|
||||
} else {
|
||||
if (reponseParsed.message == "Invalid mail") {
|
||||
setTimeout(() => {
|
||||
document.getElementById("reportBtnText").style.display = "block";
|
||||
document.getElementById("loadingSpinner").style.display = "none";
|
||||
document.getElementById("loadingDone").style.display = "none";
|
||||
document.getElementById("submitBtn").disabled = false;
|
||||
toggleModal("report-modal", false);
|
||||
form.reset();
|
||||
|
||||
document.getElementById("Geomodal-content").innerHTML =
|
||||
"It seemed like you provided an invalid mail address. Please try again.";
|
||||
toggleModal("popup-modal", true);
|
||||
}, 1000);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
document.getElementById("reportBtnText").style.display = "block";
|
||||
document.getElementById("loadingSpinner").style.display = "none";
|
||||
document.getElementById("loadingDone").style.display = "none";
|
||||
document.getElementById("submitBtn").disabled = false;
|
||||
toggleModal("report-modal", false);
|
||||
form.reset();
|
||||
|
||||
document.getElementById("Geomodal-content").innerHTML =
|
||||
"Something went wrong, please try again later";
|
||||
toggleModal("popup-modal", true);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function reportPOI(poi_id) {
|
||||
document.getElementById("pointId").innerHTML = poi_id;
|
||||
toggleModal("report-modal", true);
|
||||
/*const url = "/api/internal/report&key=b03f8aaf-1f32-4d9e-914a-9a50f904833d&"
|
||||
console.log(poi_id)*/
|
||||
}
|
||||
function httpGet(theUrl) {
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
xmlHttp.open("GET", theUrl, false); // false for synchronous request
|
||||
xmlHttp.send(null);
|
||||
return xmlHttp.responseText;
|
||||
}
|
||||
|
||||
function httpGetTriggerForMapData(theUrl) {
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
xmlHttp.open("GET", theUrl, true); // Doing it asynchronous
|
||||
xmlHttp.send(null);
|
||||
xmlHttp.onerror = function (e) {
|
||||
console.log(e);
|
||||
};
|
||||
xmlHttp.onloadend = function (e) {
|
||||
setTimeout(function () {
|
||||
if (
|
||||
xmlHttp.responseText.length > 0 &&
|
||||
!xmlHttp.responseText.includes("502 Bad Gateway")
|
||||
) {
|
||||
retryConnection = false;
|
||||
try {
|
||||
toggleModal("popup-modal-no-conn", false);
|
||||
retryConnection = false;
|
||||
} catch (error) {
|
||||
error;
|
||||
}
|
||||
response = xmlHttp.responseText;
|
||||
allMarks = 0;
|
||||
response = JSON.parse(response);
|
||||
allMarks = response;
|
||||
|
||||
markerList = [];
|
||||
for (h in response) {
|
||||
item = response[h];
|
||||
let mIcon = defaultIcon;
|
||||
if (item.icon == "signalIcon") {
|
||||
mIcon = signalIcon;
|
||||
} else if (item.icon == "cctvIcon") {
|
||||
mIcon = cctvIcon;
|
||||
} else if (item.icon == "wifiIcon") {
|
||||
mIcon = wifiIcon;
|
||||
} else if (item.icon == "temperatureIcon") {
|
||||
mIcon = temperatureIcon;
|
||||
}
|
||||
|
||||
var marker = new theMarker([item.location.x, item.location.y], {
|
||||
icon: mIcon,
|
||||
object: item,
|
||||
}).on("click", onClick);
|
||||
markerList.push(marker);
|
||||
}
|
||||
// response.forEach(addPin);
|
||||
markers.clearLayers();
|
||||
markers.addLayers(markerList);
|
||||
mymap.addLayer(markers);
|
||||
syncBtn.state("default"); // Make sure the button is back to default
|
||||
} else {
|
||||
try {
|
||||
if (!retryConnection) {
|
||||
toggleModal("popup-modal-no-conn", true);
|
||||
}
|
||||
|
||||
retryConnection = true;
|
||||
} catch (error) {
|
||||
error;
|
||||
}
|
||||
}
|
||||
}, 50);
|
||||
};
|
||||
}
|
||||
|
||||
// Try to find where to user is
|
||||
function home() {
|
||||
if (navigator.geolocation) {
|
||||
setTimeout(function () {
|
||||
navigator.geolocation.getCurrentPosition(showPosition);
|
||||
}, 200);
|
||||
} else {
|
||||
console.warn("Geolocation of user could not be fetched");
|
||||
}
|
||||
}
|
||||
|
||||
home();
|
||||
|
||||
let allMarks = [];
|
||||
var layerGroup = L.layerGroup().addTo(mymap);
|
||||
var scale = L.control.scale().addTo(mymap);
|
||||
var locator = L.control
|
||||
.locate({
|
||||
onLocationError: function (err) {
|
||||
console.log(err);
|
||||
let tip = err.message;
|
||||
if (err.message.indexOf("User denied Geolocation") > -1) {
|
||||
tip =
|
||||
"You have denied the location request. Please allow it in your browser settings.";
|
||||
}
|
||||
document.getElementById("Geomodal-content").innerHTML = tip;
|
||||
toggleModal("popup-modal", true);
|
||||
},
|
||||
})
|
||||
.addTo(mymap);
|
||||
|
||||
/*mymap.addControl(
|
||||
new L.Control.Fullscreen({
|
||||
title: {
|
||||
false: "View Fullscreen",
|
||||
true: "Exit Fullscreen",
|
||||
},
|
||||
})
|
||||
);*/
|
||||
|
||||
var sidebar = L.control.sidebar("sidebar", {
|
||||
closeButton: true,
|
||||
position: "right",
|
||||
});
|
||||
mymap.addControl(sidebar);
|
||||
|
||||
var sidebar2 = L.control.sidebar("sidebar-left", {
|
||||
// Filter one
|
||||
closeButton: true,
|
||||
position: "left",
|
||||
});
|
||||
mymap.addControl(sidebar2);
|
||||
// sidebar2.setContent(httpGet("/templates/filterPage.html"));
|
||||
|
||||
L.easyButton("fa-filter", function (btn, map) {
|
||||
if (sidebar2.isVisible()) {
|
||||
sidebar2.hide();
|
||||
} else {
|
||||
sidebar2.show();
|
||||
}
|
||||
}).addTo(mymap);
|
||||
|
||||
syncBtn = L.easyButton({
|
||||
states: [
|
||||
{
|
||||
stateName: "default", // name the state
|
||||
icon: "fa-sync", // and define its properties
|
||||
title: "Reload POIs", // like its title
|
||||
onClick: function (btn, map) {
|
||||
// and its callback
|
||||
updatePois(); // Update all da fancy POIs
|
||||
btn.state("loading"); // change state on click!
|
||||
},
|
||||
},
|
||||
{
|
||||
stateName: "loading",
|
||||
icon: "fa-sync fa-spin",
|
||||
title: "Reloading...",
|
||||
},
|
||||
],
|
||||
});
|
||||
syncBtn.addTo(mymap);
|
||||
|
||||
searchBtn = L.easyButton({
|
||||
states: [
|
||||
{
|
||||
stateName: "default", // name the state
|
||||
icon: "fa-search", // and define its properties
|
||||
title: "Search", // like its title
|
||||
onClick: function (btn, map) {
|
||||
// and its callback
|
||||
sear.toggle();
|
||||
btn.state("search"); // change state on click!
|
||||
},
|
||||
},
|
||||
{
|
||||
stateName: "search",
|
||||
icon: "fa-search fa-spin",
|
||||
title: "Hide search",
|
||||
onClick: function (btn, map) {
|
||||
// and its callback
|
||||
sear.toggle();
|
||||
btn.state("default"); // change state on click!
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
searchBtn.addTo(mymap);
|
||||
|
||||
// Start getting the pois
|
||||
setTimeout(updatePois, 500);
|
||||
var additionalFilters = "";
|
||||
function updatePois() {
|
||||
// Create a filter string
|
||||
const enabledFilters = [];
|
||||
try {
|
||||
for (fi in tagsAvail) {
|
||||
const tag = tagsAvail[fi];
|
||||
if (document.getElementById("tag_" + tag).checked ) {
|
||||
enabledFilters.push(tag);
|
||||
}
|
||||
}
|
||||
additionalFilters =
|
||||
'{"conjunction": "OR", "filters": [["tag","' + enabledFilters.join('"],["tag","') + '"]]}';
|
||||
} catch (error) {
|
||||
console.log("Filter sidebar seems not ready yet");
|
||||
}
|
||||
|
||||
console.log(additionalFilters);
|
||||
const bounds = mymap.getBounds();
|
||||
httpGetTriggerForMapData(
|
||||
"/api/getPOI?boundingEast=" +
|
||||
bounds.getNorthEast().lat +
|
||||
";" +
|
||||
bounds.getNorthEast().lng +
|
||||
"&boundingWest=" +
|
||||
bounds.getSouthWest().lat +
|
||||
";" +
|
||||
bounds.getSouthWest().lng +
|
||||
"&key=b03f8aaf-1f32-4d9e-914a-9a50f904833d&filter=" +
|
||||
additionalFilters
|
||||
);
|
||||
}
|
||||
|
||||
let prevZoom = mymap.getZoom();
|
||||
let prevCenter = mymap.getCenter();
|
||||
let hasCenterChanged = false;
|
||||
let maxZoomReached = mymap.getZoom();
|
||||
|
||||
setTimeout(function () {
|
||||
prevCenter = mymap.getCenter();
|
||||
prevZoom = mymap.getZoom();
|
||||
}, 200);
|
||||
|
||||
function getDistanceBetweenCoordinates(lat1, lon1, lat2, lon2) {
|
||||
var R = 6371; // Radius of the earth in km
|
||||
var dLat = deg2rad(lat2 - lat1); // deg2rad below
|
||||
var dLon = deg2rad(lon2 - lon1);
|
||||
var a =
|
||||
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
||||
Math.cos(deg2rad(lat1)) *
|
||||
Math.cos(deg2rad(lat2)) *
|
||||
Math.sin(dLon / 2) *
|
||||
Math.sin(dLon / 2);
|
||||
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
var d = R * c; // Distance in km
|
||||
return d;
|
||||
}
|
||||
|
||||
function deg2rad(deg) {
|
||||
return deg * (Math.PI / 180);
|
||||
}
|
||||
|
||||
mymap.on("dragend", function () {
|
||||
console.info(
|
||||
getDistanceBetweenCoordinates(
|
||||
prevCenter.lat,
|
||||
prevCenter.lng,
|
||||
mymap.getCenter().lat,
|
||||
mymap.getCenter().lng
|
||||
)
|
||||
);
|
||||
if (
|
||||
getDistanceBetweenCoordinates(
|
||||
prevCenter.lat,
|
||||
prevCenter.lng,
|
||||
mymap.getCenter().lat,
|
||||
mymap.getCenter().lng
|
||||
) >= 20
|
||||
) {
|
||||
setTimeout(updatePois, 2);
|
||||
console.info("Updating POIs");
|
||||
}
|
||||
prevCenter = mymap.getCenter();
|
||||
maxZoomReached = mymap.getZoom();
|
||||
hasCenterChanged = true;
|
||||
});
|
||||
|
||||
mymap.on("zoomend", function () {
|
||||
console.info(mymap.getZoom() - prevZoom);
|
||||
prevZoom = mymap.getZoom();
|
||||
|
||||
if (mymap.getZoom() <= maxZoomReached) {
|
||||
maxZoomReached = mymap.getZoom();
|
||||
console.info("Updating POIs");
|
||||
setTimeout(updatePois, 2);
|
||||
} else {
|
||||
if (hasCenterChanged == false) {
|
||||
veryLongIntegerVariableWhichNoOneWillEverUseHopefully = 42;
|
||||
} else {
|
||||
console.info("Updating POIs");
|
||||
setTimeout(updatePois, 2);
|
||||
}
|
||||
}
|
||||
hasCenterChanged = false;
|
||||
});
|
||||
|
||||
function applyFilter() {
|
||||
const val = document.getElementById("filter").value;
|
||||
console.log(val);
|
||||
additionalFilters =
|
||||
'{"filters": [["tag", "' + val + '"]], "conjunction": "OR"}'; // {"filters": [["tag", "webcam"]], "conjunction": "OR"}
|
||||
updatePois();
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
let lat = -1;
|
||||
let lng = -1;
|
||||
let zoom = 5;
|
||||
let shouldThings = 0;
|
||||
let point_id = "";
|
||||
if (window.location.href.indexOf("#") > -1) {
|
||||
point_id = window.location.href.split("#")[1];
|
||||
prepareSidebar(point_id, true);
|
||||
setTimeout(updatePois, 500);
|
||||
} else {
|
||||
window.location.search
|
||||
.substr(1)
|
||||
.split("&")
|
||||
.forEach(function (item) {
|
||||
const param = item.split("=");
|
||||
if (param[0] === "lat" && _.isFinite(param[1])) {
|
||||
lat = param[1];
|
||||
shouldThings++;
|
||||
} else if (param[0] === "lng" && _.isFinite(param[1])) {
|
||||
lng = param[1];
|
||||
shouldThings++;
|
||||
} else if (param[0] === "zoom" && _.isFinite(param[1])) {
|
||||
zoom = param[1];
|
||||
shouldThings++;
|
||||
}
|
||||
if (shouldThings >= 2) {
|
||||
mymap.flyTo([lat, lng], zoom);
|
||||
console.log(lat, lng, zoom);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
|
||||
setInterval(function () {
|
||||
if (retryConnection) {
|
||||
updatePois();
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
mymap.on("contextmenu.show", (e) => {
|
||||
mymap.contextmenu.removeItem(0);
|
||||
mymap.contextmenu.insertItem(
|
||||
{
|
||||
text:
|
||||
"<b class='background-color=\"red\"'>" +
|
||||
e.latlng.lat.toFixed(4) +
|
||||
", " +
|
||||
e.latlng.lng.toFixed(4) +
|
||||
"</b>",
|
||||
callback: copyLocation,
|
||||
},
|
||||
0
|
||||
);
|
||||
});
|
||||
sear = L.control.search({ position: "topleft" });
|
||||
|
||||
mymap.addControl(sear);
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this.parsedData=[];for(var b=[],d=0,e=this.data.length;e>d;d++){var f=this.data.charCodeAt(d);f>65536?(b[0]=240|(1835008&f)>>>18,b[1]=128|(258048&f)>>>12,b[2]=128|(4032&f)>>>6,b[3]=128|63&f):f>2048?(b[0]=224|(61440&f)>>>12,b[1]=128|(4032&f)>>>6,b[2]=128|63&f):f>128?(b[0]=192|(1984&f)>>>6,b[1]=128|63&f):b[0]=f,this.parsedData=this.parsedData.concat(b)}this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function b(a,b){this.typeNumber=a,this.errorCorrectLevel=b,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function i(a,b){if(void 0==a.length)throw new Error(a.length+"/"+b);for(var c=0;c<a.length&&0==a[c];)c++;this.num=new Array(a.length-c+b);for(var d=0;d<a.length-c;d++)this.num[d]=a[d+c]}function j(a,b){this.totalCount=a,this.dataCount=b}function k(){this.buffer=[],this.length=0}function m(){return"undefined"!=typeof CanvasRenderingContext2D}function n(){var a=!1,b=navigator.userAgent;return/android/i.test(b)&&(a=!0,aMat=b.toString().match(/android ([0-9]\.[0-9])/i),aMat&&aMat[1]&&(a=parseFloat(aMat[1]))),a}function r(a,b){for(var c=1,e=s(a),f=0,g=l.length;g>=f;f++){var h=0;switch(b){case d.L:h=l[f][0];break;case d.M:h=l[f][1];break;case d.Q:h=l[f][2];break;case d.H:h=l[f][3]}if(h>=e)break;c++}if(c>l.length)throw new Error("Too long data");return c}function s(a){var b=encodeURI(a).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return b.length+(b.length!=a?3:0)}a.prototype={getLength:function(){return this.parsedData.length},write:function(a){for(var b=0,c=this.parsedData.length;c>b;b++)a.put(this.parsedData[b],8)}},b.prototype={addData:function(b){var c=new a(b);this.dataList.push(c),this.dataCache=null},isDark:function(a,b){if(0>a||this.moduleCount<=a||0>b||this.moduleCount<=b)throw new Error(a+","+b);return this.modules[a][b]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(a,c){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var d=0;d<this.moduleCount;d++){this.modules[d]=new Array(this.moduleCount);for(var e=0;e<this.moduleCount;e++)this.modules[d][e]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(a,c),this.typeNumber>=7&&this.setupTypeNumber(a),null==this.dataCache&&(this.dataCache=b.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,c)},setupPositionProbePattern:function(a,b){for(var c=-1;7>=c;c++)if(!(-1>=a+c||this.moduleCount<=a+c))for(var d=-1;7>=d;d++)-1>=b+d||this.moduleCount<=b+d||(this.modules[a+c][b+d]=c>=0&&6>=c&&(0==d||6==d)||d>=0&&6>=d&&(0==c||6==c)||c>=2&&4>=c&&d>=2&&4>=d?!0:!1)},getBestMaskPattern:function(){for(var a=0,b=0,c=0;8>c;c++){this.makeImpl(!0,c);var d=f.getLostPoint(this);(0==c||a>d)&&(a=d,b=c)}return b},createMovieClip:function(a,b,c){var d=a.createEmptyMovieClip(b,c),e=1;this.make();for(var f=0;f<this.modules.length;f++)for(var g=f*e,h=0;h<this.modules[f].length;h++){var i=h*e,j=this.modules[f][h];j&&(d.beginFill(0,100),d.moveTo(i,g),d.lineTo(i+e,g),d.lineTo(i+e,g+e),d.lineTo(i,g+e),d.endFill())}return d},setupTimingPattern:function(){for(var a=8;a<this.moduleCount-8;a++)null==this.modules[a][6]&&(this.modules[a][6]=0==a%2);for(var b=8;b<this.moduleCount-8;b++)null==this.modules[6][b]&&(this.modules[6][b]=0==b%2)},setupPositionAdjustPattern:function(){for(var a=f.getPatternPosition(this.typeNumber),b=0;b<a.length;b++)for(var c=0;c<a.length;c++){var d=a[b],e=a[c];if(null==this.modules[d][e])for(var g=-2;2>=g;g++)for(var h=-2;2>=h;h++)this.modules[d+g][e+h]=-2==g||2==g||-2==h||2==h||0==g&&0==h?!0:!1}},setupTypeNumber:function(a){for(var b=f.getBCHTypeNumber(this.typeNumber),c=0;18>c;c++){var d=!a&&1==(1&b>>c);this.modules[Math.floor(c/3)][c%3+this.moduleCount-8-3]=d}for(var c=0;18>c;c++){var d=!a&&1==(1&b>>c);this.modules[c%3+this.moduleCount-8-3][Math.floor(c/3)]=d}},setupTypeInfo:function(a,b){for(var c=this.errorCorrectLevel<<3|b,d=f.getBCHTypeInfo(c),e=0;15>e;e++){var g=!a&&1==(1&d>>e);6>e?this.modules[e][8]=g:8>e?this.modules[e+1][8]=g:this.modules[this.moduleCount-15+e][8]=g}for(var e=0;15>e;e++){var g=!a&&1==(1&d>>e);8>e?this.modules[8][this.moduleCount-e-1]=g:9>e?this.modules[8][15-e-1+1]=g:this.modules[8][15-e-1]=g}this.modules[this.moduleCount-8][8]=!a},mapData:function(a,b){for(var c=-1,d=this.moduleCount-1,e=7,g=0,h=this.moduleCount-1;h>0;h-=2)for(6==h&&h--;;){for(var i=0;2>i;i++)if(null==this.modules[d][h-i]){var j=!1;g<a.length&&(j=1==(1&a[g]>>>e));var k=f.getMask(b,d,h-i);k&&(j=!j),this.modules[d][h-i]=j,e--,-1==e&&(g++,e=7)}if(d+=c,0>d||this.moduleCount<=d){d-=c,c=-c;break}}}},b.PAD0=236,b.PAD1=17,b.createData=function(a,c,d){for(var e=j.getRSBlocks(a,cLine truncated
|
||||
@@ -0,0 +1,74 @@
|
||||
/* eslint-disable no-undef */
|
||||
function httpGet(theUrl) {
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
xmlHttp.open("GET", theUrl, false); // false for synchronous request
|
||||
try {
|
||||
xmlHttp.send(null);
|
||||
} catch (error) {
|
||||
try {
|
||||
if (!retryConnection) {
|
||||
toggleModal("popup-modal-no-conn", true);
|
||||
}
|
||||
|
||||
retryConnection = true;
|
||||
} catch (error) {
|
||||
error;
|
||||
}
|
||||
}
|
||||
|
||||
return xmlHttp.responseText;
|
||||
}
|
||||
|
||||
function home() {
|
||||
if (navigator.geolocation) {
|
||||
setTimeout(function () {
|
||||
navigator.geolocation.getCurrentPosition(showPosition);
|
||||
}, 200);
|
||||
} else {
|
||||
console.warn("Geolocation of user could not be fetched");
|
||||
}
|
||||
}
|
||||
|
||||
function on() {
|
||||
document.getElementById("overlay").style.display = "block";
|
||||
}
|
||||
|
||||
function off() {
|
||||
document.getElementById("overlay").style.display = "none";
|
||||
}
|
||||
|
||||
function makeToastNotification(title, message) {
|
||||
document.getElementById("notificationToast").style.display = "block";
|
||||
document.getElementById("toast_title").innerHTML = title;
|
||||
document.getElementById("toast_desc").innerHTML = message;
|
||||
try {
|
||||
setTimeout(function () {
|
||||
document
|
||||
.getElementById("notificationToast")
|
||||
.classList.remove("animate-right");
|
||||
document
|
||||
.getElementById("notificationToast")
|
||||
.classList.add("animate-right-back");
|
||||
setTimeout(function () {
|
||||
document.getElementById("notificationToast").style.display = "none";
|
||||
setTimeout(function () {
|
||||
document
|
||||
.getElementById("notificationToast")
|
||||
.classList.add("animate-right");
|
||||
document
|
||||
.getElementById("notificationToast")
|
||||
.classList.remove("animate-right-back");
|
||||
}, 50);
|
||||
}, 500);
|
||||
}, 2000);
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
"Failed to show toast notification with title: `" +
|
||||
title +
|
||||
"` and message: `" +
|
||||
message +
|
||||
"`"
|
||||
);
|
||||
alert(title + " \n" + message);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user