Skip to content

Commit

Permalink
remove geolocation by ip
Browse files Browse the repository at this point in the history
  • Loading branch information
strukturart committed Jun 18, 2024
1 parent 04180cd commit 0d7de1b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 58 deletions.
13 changes: 2 additions & 11 deletions application/assets/js/settings.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const settings = ((_) => {
let save_settings = function () {
localStorage.setItem("owm-key", document.getElementById("owm-key").value);
localStorage.setItem(
"ipbase-key",
document.getElementById("ipbase-key").value
);

localStorage.setItem(
"routing_profil",
Expand Down Expand Up @@ -78,9 +74,7 @@ const settings = ((_) => {
localStorage["tracking-notification-time"] || 0,

openweather_api: localStorage.getItem("owm-key"),
ipbase_api: localStorage.getItem("ipbase-key")
? localStorage.getItem("ipbase-key")
: "",

ors_api: localStorage.getItem("ors-key"),
routing_profil: localStorage.getItem("routing_profil")
? localStorage.getItem("routing_profil")
Expand Down Expand Up @@ -176,7 +170,6 @@ const settings = ((_) => {
//set values in setting page

document.getElementById("owm-key").value = setting.openweather_api;
document.getElementById("ipbase-key").value = setting.ipbase_api;
document.getElementById("ors-key").value = setting.ors_api;
document.getElementById("routing-profil").value = setting.routing_profil;

Expand Down Expand Up @@ -244,7 +237,6 @@ const settings = ((_) => {

setTimeout(() => {
document.getElementById("owm-key").value = setting.openweather_api;
document.getElementById("ipbase-key").value = setting.ipbase_api;
document.getElementById("ors-key").value = setting.ors_api;
document.getElementById("routing-profil").value =
setting.routing_profil;
Expand Down Expand Up @@ -293,8 +285,7 @@ const settings = ((_) => {
setTimeout(() => {
document.getElementById("owm-key").value =
setting.openweather_api;
document.getElementById("ipbase-key").value =
setting.ipbase_api;

document.getElementById("ors-key").value =
setting.ors_api;
document.getElementById("routing-profil").value =
Expand Down
6 changes: 0 additions & 6 deletions application/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,6 @@ <h2>Routing Service</h2>
<div class="toogle-button"></div>
</div>

<h2>IP Geolocation</h2>
<div class="item input-parent" tabindex="0">
<label for="ipbase-key">ipbase.com API-Key</label>
<input type="text" class="qr" id="ipbase-key" />
</div>

<h2>Crosshair</h2>
<div class="item input-parent flex" tabindex="3">
<label for="crosshair-ckb" class="grid-col-14"
Expand Down
55 changes: 14 additions & 41 deletions application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,20 +346,6 @@ document.addEventListener("DOMContentLoaded", function () {
helper.getManifest(manifest);
}

let geoip_callback = function (data) {
helper.side_toaster(
"your position was found out via your ip address, the accuracy is rather poor",
2000
);
mainmarker.current_lat = data[0];
mainmarker.current_lng = data[1];
mainmarker.device_lat = data[0];
mainmarker.device_lng = data[1];
myMarker.setLatLng([mainmarker.device_lat, mainmarker.device_lng]).update();
setTimeout(function () {
map.setView([mainmarker.device_lat, mainmarker.device_lng], 12);
}, 1000);
};
//build menu
let build_menu = function () {
let el = document.querySelector("div#maps");
Expand Down Expand Up @@ -989,33 +975,20 @@ document.addEventListener("DOMContentLoaded", function () {
}

function error(err) {
if (setting.ipbase_api != "") {
var z = confirm(
"do you want to find out your position by your ip address ?"
);
}

if (z == true) {
helper.geoip(geoip_callback, setting.ipbase_api);
} else {
helper.side_toaster(
"Position not found, load last known position",
4000
);
mainmarker.current_lat = mainmarker.last_location[0];
mainmarker.current_lng = mainmarker.last_location[1];
mainmarker.current_alt = 0;

mainmarker.device_lat = mainmarker.last_location[0];
mainmarker.device_lng = mainmarker.last_location[1];
geolocationWatch();
myMarker
.setLatLng([mainmarker.device_lat, mainmarker.device_lng])
.update();
setTimeout(function () {
map.setView([mainmarker.device_lat, mainmarker.device_lng], 12);
}, 1000);
}
helper.side_toaster("Position not found, load last known position", 4000);
mainmarker.current_lat = mainmarker.last_location[0];
mainmarker.current_lng = mainmarker.last_location[1];
mainmarker.current_alt = 0;

mainmarker.device_lat = mainmarker.last_location[0];
mainmarker.device_lng = mainmarker.last_location[1];
geolocationWatch();
myMarker
.setLatLng([mainmarker.device_lat, mainmarker.device_lng])
.update();
setTimeout(function () {
map.setView([mainmarker.device_lat, mainmarker.device_lng], 12);
}, 1000);
}

navigator.geolocation.getCurrentPosition(success, error, options);
Expand Down

0 comments on commit 0d7de1b

Please sign in to comment.