diff --git a/README.md b/README.md index 89d76a79..0a4d2dfb 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This is an Open Street Map app for the Nokia 81104G + search locations + open openstreetmap link to marker -If you want to use the openweathermap, you need to get an API key from openweathermap.org. Then you need to create a file called osm-map.json please check my example [file](/osm-map.json) +If you want to use the openweathermap, you need to get an API key from openweathermap.org. Then you need to create a file called omap.json please check my example [file](/omap.json) @@ -20,13 +20,15 @@ If you want to use the openweathermap, you need to get an API key from openweath ![image-4](/images/image-4.png) ![image-5](/images/image-5.png) ![image-6](/images/image-6.png) - +![image-7](/images/image-7.png) +![image-8](/images/image-8.png) ## Maps + Openstreetmap + Open Topo Map + Tonner Map ++ Moon Map ## Layers + OpenWeatherMap @@ -57,9 +59,15 @@ The search can be opened with key 2, you can search for locations or start the s ### Thank you ++ Openstreetmap ++ OpenTopoMap ++ http://maps.stamen.com/toner/ Tonermap ++ https://www.openplanetary.org/ Moonmap ++ leaflet.js + [Bananna Hackers Group](https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!forum/bananahackers) + Luxferre [olc](https://gist.github.com/plugnburn/95de231ff94130f1de8eb2a2afaf8516) + ### License [UNLICENSE](UNLICENSE) diff --git a/application/app.js b/application/app.js index a5980601..34f9ab03 100644 --- a/application/app.js +++ b/application/app.js @@ -9,7 +9,6 @@ let altitude; let current_heading; - let zoom_level; let current_zoom_level; let new_lat = 0; @@ -40,6 +39,7 @@ let marker_latlng = false; let file_path; let storage_name; +let json_modified = false; @@ -51,9 +51,13 @@ $(document).ready(function() { $('div#message').css("display", "none") //get location if not an activity open url if (open_url === false) { + read_json(); getLocation("init"); toaster("Press 3
to open the menu", 5000) + setTimeout(function() { + $('.leaflet-control-attribution').hide() + }, 8000); } ///set default map opentopo_map(); @@ -77,6 +81,19 @@ $(document).ready(function() { ////MAPS//////////// /////////////////// + function moon_map() { + tilesUrl = 'https://cartocdn-gusc.global.ssl.fastly.net/opmbuilder/api/v1/map/named/opm-moon-basemap-v0-1/all/{z}/{x}/{y}.png' + tilesLayer = L.tileLayer(tilesUrl, { + maxZoom: 12, + minZoom: 2, + attribution: 'Map data © OpenStreetMap contributors, ' + + 'CC-BY-SA' + }); + + map.addLayer(tilesLayer); + + } + function toner_map() { tilesUrl = 'https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png' tilesLayer = L.tileLayer(tilesUrl, { @@ -97,11 +114,6 @@ $(document).ready(function() { }); map.addLayer(tilesLayer); - - setTimeout(function() { - $('.leaflet-control-attribution').hide() - }, 4000); - } @@ -132,6 +144,8 @@ $(document).ready(function() { } + + ///////////////////////// //read json to build menu ///////////////////////// @@ -167,9 +181,10 @@ $(document).ready(function() { $("div#maps").append('
Toner Map
'); $("div#maps").append('
OSM Map
'); $("div#maps").append('
OpenTopo Map
'); + $("div#maps").append('
Moon Map
'); - let reader = new FileReader() + let reader = new FileReader() reader.onerror = function(event) { toaster("can't read file") @@ -178,8 +193,6 @@ $(document).ready(function() { reader.onloadend = function(event) { - - let data; //check if json valid try { @@ -189,8 +202,6 @@ $(document).ready(function() { return false; } - - //add markers and openweatermap $.each(data, function(index, value) { @@ -206,74 +217,105 @@ $(document).ready(function() { } - }) + find_gpx(); + find_geojson(); if (option == "finder") { - + finder_tabindex(); + $('div#finder').css('display', 'block'); windowOpen = "finder"; + $('div#finder').find('div.items[tabindex=0]').focus(); - //search geojson - let finder = new Applait.Finder({ type: "sdcard", debugMode: false }); - finder.search(".geojson"); + json_modified = false; + } - finder.on("searchComplete", function(needle, filematchcount) { + }; + reader.readAsText(file) + }); + } - //set tabindex - $('div.items').each(function(index, value) { - let $div = $(this) - $div.attr("tabindex", index); - }); + ////////////////////////////////// + //READ GPX//////////////////////// + ///////////////////////////////// + let find_gpx = function() { - $('div#finder').css('display', 'block'); - $('div#finder').find('div.items[tabindex=0]').focus(); - tabIndex = 0; + //search gpx + let finder_gpx = new Applait.Finder({ type: "sdcard", debugMode: false }); - }); + finder_gpx.search(".gpx"); + finder_gpx.on("searchComplete", function(needle, filematchcount) { + }); - finder.on("fileFound", function(file, fileinfo, storageName) { - $("div#tracks").append('
' + fileinfo.name + '
'); - }); + finder_gpx.on("fileFound", function(file, fileinfo, storageName) { + $("div#tracks").append('
' + fileinfo.name + '
'); + }); - //search gpx - let finder_gpx = new Applait.Finder({ type: "sdcard", debugMode: false }); - finder_gpx.search(".gpx"); + } - finder_gpx.on("searchComplete", function(needle, filematchcount) { - //set tabindex - $('div.items').each(function(index, value) { - let $div = $(this) - $div.attr("tabindex", index); - }); + ////////////////////////////////// + //READ GEOJSON//////////////////////// + ///////////////////////////////// + let find_geojson = function() { - $('div#finder').css('display', 'block'); - $('div#finder').find('div.items[tabindex=0]').focus(); - tabIndex = 0; + //search geojson + let finder = new Applait.Finder({ type: "sdcard", debugMode: false }); + finder.search(".geojson"); - }); + finder.on("searchComplete", function(needle, filematchcount) {}) - finder_gpx.on("fileFound", function(file, fileinfo, storageName) { - $("div#tracks").append('
' + fileinfo.name + '
'); - }); - } + finder.on("fileFound", function(file, fileinfo, storageName) { + $("div#tracks").append('
' + fileinfo.name + '
'); + }); - }; - reader.readAsText(file) + } + + + ////////////////////////////////// + ///MENU////////////////////////// + ///////////////////////////////// + + let show_finder = function() { + if (json_modified) { + read_json("finder") + } else { + finder_tabindex() + $('div#finder').find('div.items[tabindex=0]').focus(); + $('div#finder').css('display', 'block'); + windowOpen = "finder"; + } + } + + + + + let finder_tabindex = function() { + //set tabindex + $('div.items').each(function(index, value) { + let $div = $(this) + $div.attr("tabindex", index); }); + + $('div#finder').css('display', 'block'); + $('div#finder').find('div.items[tabindex=0]').focus(); + tabIndex = 0; + } - read_json() + + + @@ -396,7 +438,7 @@ $(document).ready(function() { if (option == "init") { myMarker = L.marker([current_lat, current_lng]).addTo(map); - map.setView([current_lat, current_lng], 14); + map.setView([current_lat, current_lng], 12); zoom_speed(); $('div#message div').text(""); return false; @@ -405,7 +447,7 @@ $(document).ready(function() { if (option == "update_marker" && current_lat != "") { myMarker.setLatLng([current_lat, current_lng]).update(); - map.flyTo(new L.LatLng(current_lat, current_lng), 12); + map.flyTo(new L.LatLng(current_lat, current_lng), 10); zoom_speed() } @@ -569,7 +611,7 @@ $(document).ready(function() { if (option == "delete_marker") { - + json_modified = true; var markers = []; @@ -582,9 +624,6 @@ $(document).ready(function() { data[0].markers = markers; - - - save(); } @@ -601,6 +640,8 @@ $(document).ready(function() { requestAdd.onsuccess = function() { + json_modified = true; + if (option == "delete_marker") { toaster('Marker deleted', 2000); $(":focus").css("display", "none") @@ -614,6 +655,7 @@ $(document).ready(function() { windowOpen = "finder"; + } if (option == "save_marker") { toaster('Marker saved', 2000); @@ -628,21 +670,15 @@ $(document).ready(function() { windowOpen = "map"; } - - } requestAdd.onerror = function() { toaster('Unable to write the file: ' + this.error, 2000); } - }, 2000); } - - - }) reader.readAsText(fileget); } @@ -689,6 +725,14 @@ $(document).ready(function() { windowOpen = "map"; } + if (item_value == "moon") { + map.removeLayer(tilesLayer); + moon_map(); + $('div#finder').css('display', 'none'); + map.setZoom(4); + windowOpen = "map"; + } + if (item_value == "otm") { map.removeLayer(tilesLayer); @@ -708,7 +752,6 @@ $(document).ready(function() { if (item_value == "share") { osm_map(); getLocation("share") - } @@ -723,7 +766,6 @@ $(document).ready(function() { if (item_value == "update-position") { - getLocation("update_marker") } @@ -1272,7 +1314,8 @@ $(document).ready(function() { case '3': param.preventDefault() - read_json("finder") + //read_json("finder") + show_finder() break; case '4': diff --git a/application/index.html b/application/index.html index fe4492ae..890f0b75 100644 --- a/application/index.html +++ b/application/index.html @@ -81,7 +81,7 @@

Options

-
+
update geolocation
1
@@ -145,15 +145,6 @@

TRACKS

Markers

- - - - -
- - - -
Do you want unload the current map ?
diff --git a/application/manifest.webapp b/application/manifest.webapp index f9554b21..7d8fcfa7 100644 --- a/application/manifest.webapp +++ b/application/manifest.webapp @@ -1,6 +1,6 @@ { - "version": "1.0.0", - "name": "osm-map", + "version": "1.1.0", + "name": "o.map", "description": "OpenStreetMap", "launch_path": "/index.html", "type": "privileged", diff --git a/build/osm-map.zip b/build/omap.zip old mode 100755 new mode 100644 similarity index 67% rename from build/osm-map.zip rename to build/omap.zip index 55a64891..a3cc3e4f Binary files a/build/osm-map.zip and b/build/omap.zip differ diff --git a/images/image-7.png b/images/image-7.png new file mode 100755 index 00000000..d058a223 Binary files /dev/null and b/images/image-7.png differ diff --git a/images/image-8.png b/images/image-8.png new file mode 100755 index 00000000..0153562f Binary files /dev/null and b/images/image-8.png differ diff --git a/osm-map.json b/omap.json similarity index 100% rename from osm-map.json rename to omap.json