diff --git a/application/assets/js/osm.js b/application/assets/js/osm.js index 3b0f82ca..89acfbdc 100644 --- a/application/assets/js/osm.js +++ b/application/assets/js/osm.js @@ -110,9 +110,10 @@ const osm = (() => { xhr.setRequestHeader("Authorization", n); xhr.onload = function () { + helper.side_toaster("file uploaded", 5000); + if (xhr.status === 200) { const data = xhr.responseText; - helper.side_toaster("file updated", 2000); } else { const error = "Error: " + xhr.status; helper.side_toaster(error, 4000); @@ -273,7 +274,7 @@ const osm = (() => { }; files.push({ - name: "_" + m.name, + name: "+ " + m.name, path: m.id, id: m.id, type: "osm_sever", @@ -292,7 +293,7 @@ const osm = (() => { }; files.push({ - name: m.name, + name: "+ " + m.name, path: m.id, id: m.id, type: "osm_sever", diff --git a/application/index.js b/application/index.js index d7a2591e..84fa2b67 100644 --- a/application/index.js +++ b/application/index.js @@ -426,8 +426,6 @@ document.addEventListener("DOMContentLoaded", function () { general.last_map_type ); - console.log(general); - //get files and store // Function to remove duplicates based on the 'name' property diff --git a/application/manifest.webapp b/application/manifest.webapp index b4c46c19..58c380d3 100644 --- a/application/manifest.webapp +++ b/application/manifest.webapp @@ -1,5 +1,5 @@ { - "version": "1.9.782", + "version": "1.9.783", "version_name": "hotline", "name": "o.map", "description": "O.map, your ultimate navigation companion for KaiOS-powered devices. O.map is a lightweight and feature-rich map application designed specifically for KaiOS, enabling you to explore and navigate the world with ease. Whether you're a local resident, a tourist, or an adventurer, O.map is here to enhance your journey and keep you on the right track.", diff --git a/application/manifest.webmanifest b/application/manifest.webmanifest index b2ffc351..a4a4ce83 100644 --- a/application/manifest.webmanifest +++ b/application/manifest.webmanifest @@ -21,7 +21,7 @@ ], "b2g_features": { - "version": "2.0.87", + "version": "2.0.88", "id": "o.map", "core": true, "categories": ["utilities"], diff --git a/docs/assets/js/module.js b/docs/assets/js/module.js index 70c6d501..cfa75a44 100644 --- a/docs/assets/js/module.js +++ b/docs/assets/js/module.js @@ -386,7 +386,6 @@ const module = (() => { let select_marker = function () { index++; let markers_collection = []; //makers in map boundingbox - let polyline_collection = []; // Reset contained list overpass_group.eachLayer(function (l) { @@ -420,6 +419,7 @@ const module = (() => { //show selected marker map.setView(markers_collection[index].getLatLng()); + console.log(markers_collection[index]); //popup document.querySelector("input#popup").value = ""; @@ -492,10 +492,18 @@ const module = (() => { map.setView(polyline_collection[index_polyline].getCenter()); + // console.log(polyline_collection[index_polyline].markers); + /* hh.getLatLngs().forEach((e) => { L.marker(e) .addTo(selected_polyline_markers_group) .setIcon(maps.public_transport); + });*/ + + polyline_collection[index_polyline].markers.forEach((e) => { + L.marker(e.latlng) + .addTo(selected_polyline_markers_group) + .setIcon(maps.public_transport); }); } catch (e) {} diff --git a/docs/assets/js/osm.js b/docs/assets/js/osm.js index 3b0f82ca..89acfbdc 100644 --- a/docs/assets/js/osm.js +++ b/docs/assets/js/osm.js @@ -110,9 +110,10 @@ const osm = (() => { xhr.setRequestHeader("Authorization", n); xhr.onload = function () { + helper.side_toaster("file uploaded", 5000); + if (xhr.status === 200) { const data = xhr.responseText; - helper.side_toaster("file updated", 2000); } else { const error = "Error: " + xhr.status; helper.side_toaster(error, 4000); @@ -273,7 +274,7 @@ const osm = (() => { }; files.push({ - name: "_" + m.name, + name: "+ " + m.name, path: m.id, id: m.id, type: "osm_sever", @@ -292,7 +293,7 @@ const osm = (() => { }; files.push({ - name: m.name, + name: "+ " + m.name, path: m.id, id: m.id, type: "osm_sever", diff --git a/docs/assets/js/overpass.js b/docs/assets/js/overpass.js index 6d005abd..40bf357b 100644 --- a/docs/assets/js/overpass.js +++ b/docs/assets/js/overpass.js @@ -24,10 +24,12 @@ const overpass = (() => { let public_transport = false; let relation_query = "[" + overpassQuery + "]"; - let way_query = overpassQuery; + let way_query = "[" + overpassQuery + "]"; + let node_query = "[" + overpassQuery + "]"; if (overpassQuery.indexOf("public_transport") > -1) { + node_query = "['public_transport'='stop_position']['bus'='yes']"; relation_query = "['type'='route']['route'='bus']"; - way_query = "public_transport=platform"; + way_query = "['public_transport'='stop_platform']['bus'='yes']"; public_transport = true; } @@ -37,7 +39,6 @@ const overpass = (() => { overpass_group.eachLayer(function (layer) { if (layer.tag === overpassQuery) { - console.log("try"); overpass_group.removeLayer(layer._leaflet_id); } }); @@ -57,20 +58,20 @@ const overpass = (() => { let s = map.getBounds().getSouth(); var bounds = s + "," + w + "," + n + "," + e; - var nodeQuery = "(node[" + overpassQuery + "](" + bounds + ");"; - var wayQuery = "way[" + way_query + "](" + bounds + ");"; + var nodeQuery = "(node" + node_query + "(" + bounds + ");"; + var wayQuery = "way" + way_query + "(" + bounds + ");"; var relationQuery = "relation" + relation_query + "(" + bounds + ");)"; var query = "?data=[out:json][timeout:25];" + nodeQuery + wayQuery + relationQuery + - ";out;>;out skel%3b"; + ";out body;>;out skel%3b"; var baseUrl = "https://overpass-api.de/api/interpreter"; var resultUrl = baseUrl + query; let segmentCoords = []; - let history = ""; + let segmentCoordsMarker = []; function fetchDataWithXHR(resultUrl, callback, errorCallback) { var xhr = new XMLHttpRequest(); xhr.open("GET", resultUrl, true); @@ -137,10 +138,11 @@ const overpass = (() => { ); document.querySelector(".loading-spinner").style.display = "none"; } else { + // console.log(data); + for (let i = 0; i < data.elements.length; i++) { const element = data.elements[i]; - // Your existing logic here if (element.type === "node" && !public_transport) { let k = L.marker([element.lat, element.lon]) .addTo(overpass_group) @@ -156,50 +158,72 @@ const overpass = (() => { // Your logic for ways } + if (element.type === "way" && public_transport) { + // if (element.tags.name) console.log(element); + } + + //public transport if (element.type === "relation" && public_transport) { let f = element; - element.members.forEach((e) => { + //relation name + let relation_name = + f.tags.name !== undefined && f.tags.name !== null + ? f.tags.name + : ""; + //color + let color = + f.tags.colour !== undefined && f.tags.colour !== null + ? f.tags.colour + : generateRandomColor(); + + element.members.forEach((e, index) => { let m = data.elements.find((m) => m.id === e.ref); - let hh = ""; - try { - hh = m.tags.name; - } catch (e) {} + if (m && m.type === "node") { + if (e.role == "stop") { + segmentCoordsMarker.push({ + id: m.id, + latlng: [m.lat, m.lon], + }); + } + } if (m && m.type === "way") { + m.nodes.forEach((e) => { + let m = data.elements.find((m) => m.id === e); + + segmentCoords.push({ + id: m.id, + latlng: [m.lat, m.lon], + color: color, + name: relation_name, + }); + }); } - if (m && m.type === "node") { - //todo add tags.name as popoup - segmentCoords.push({ - latlng: [m.lat, m.lon], - popup: hh, + if (index === element.members.length - 1) { + let h = L.polyline( + segmentCoords.map((coord) => coord.latlng), + { + color: color, + weight: 4, + } + ); + + var popup = L.popup({ + maxWidth: "80%", }); - if (f.id !== history) { - segmentCoords.pop(); - let h = L.polyline( - segmentCoords.map((coord) => coord.latlng), - { - color: generateRandomColor(), - } - ); - - var popup = L.popup({ - maxWidth: "80%", - }); - - popup.setContent(f.tags.name); + popup.setContent(relation_name); - h.bindPopup(popup); - h.tag = overpassQuery; + h.bindPopup(popup); + h.tag = overpassQuery; + h.markers = segmentCoordsMarker; - h.addTo(overpass_group); - segmentCoords = []; - } - - history = f.id; + h.addTo(overpass_group); + segmentCoords = []; + segmentCoordsMarker = []; } }); } @@ -212,6 +236,8 @@ const overpass = (() => { } }, function (err) { + document.querySelector(".loading-spinner").style.display = "none"; + helper.side_toaster("something went wrong, try again" + err, 6000); } ); diff --git a/docs/index.js b/docs/index.js index d7a2591e..84fa2b67 100644 --- a/docs/index.js +++ b/docs/index.js @@ -426,8 +426,6 @@ document.addEventListener("DOMContentLoaded", function () { general.last_map_type ); - console.log(general); - //get files and store // Function to remove duplicates based on the 'name' property diff --git a/docs/manifest.webapp b/docs/manifest.webapp index b4c46c19..58c380d3 100644 --- a/docs/manifest.webapp +++ b/docs/manifest.webapp @@ -1,5 +1,5 @@ { - "version": "1.9.782", + "version": "1.9.783", "version_name": "hotline", "name": "o.map", "description": "O.map, your ultimate navigation companion for KaiOS-powered devices. O.map is a lightweight and feature-rich map application designed specifically for KaiOS, enabling you to explore and navigate the world with ease. Whether you're a local resident, a tourist, or an adventurer, O.map is here to enhance your journey and keep you on the right track.", diff --git a/docs/manifest.webmanifest b/docs/manifest.webmanifest index b2ffc351..a4a4ce83 100644 --- a/docs/manifest.webmanifest +++ b/docs/manifest.webmanifest @@ -21,7 +21,7 @@ ], "b2g_features": { - "version": "2.0.87", + "version": "2.0.88", "id": "o.map", "core": true, "categories": ["utilities"],