mirror of https://github.com/espruino/BangleApps
Allow setting location from webinterface in the AppLoader
parent
72265bebff
commit
998855b099
|
@ -5,3 +5,4 @@
|
|||
0.05: Fixed issue with back option
|
||||
0.06: renamed source files to match standard
|
||||
0.07: Move mylocation app into 'Settings -> Apps'
|
||||
0.08: Allow setting location from webinterface in the AppLoader
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
To access, go to `Settings -> Apps -> My Location`
|
||||
|
||||
* Select one of the preset Cities or setup through the GPS
|
||||
* Select one of the preset Cities, setup through the GPS or use the webinterface from the AppLoader
|
||||
* Other Apps can read this information to do calculations based on location
|
||||
* When the City shows ??? it means the location has been set through the GPS
|
||||
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
|
||||
<link rel="stylesheet" href="../../css/spectre.min.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet-geosearch@3.6.0/dist/geosearch.css"/>
|
||||
</head>
|
||||
<style>
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
html, body, #map {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
#map { z-index: 1; }
|
||||
#controls {
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border: 1px solid black;
|
||||
position:absolute;
|
||||
right:0px;top:0px;
|
||||
background-color: rgb(255, 255, 255);
|
||||
z-index: 100;
|
||||
}
|
||||
#maptiles {
|
||||
width: 256px;
|
||||
height: 256px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map">
|
||||
</div>
|
||||
<div id="controls">
|
||||
<button id="select" class="btn btn-primary" style="display:none">Save</button><br/>
|
||||
</div>
|
||||
|
||||
<script src="../../core/lib/customize.js"></script>
|
||||
<script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
|
||||
<script src="../../core/lib/heatshrink.js"></script>
|
||||
<script src="../../core/lib/imageconverter.js"></script>
|
||||
<script src="https://unpkg.com/leaflet-geosearch@3.6.0/dist/bundle.min.js"></script>
|
||||
|
||||
<script>
|
||||
var TILELAYER = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
|
||||
var map = L.map('map').locate({setView: true, maxZoom: 16, enableHighAccuracy:true});
|
||||
var tileLayer = L.tileLayer(TILELAYER, {
|
||||
maxZoom: 18,
|
||||
attribution: 'Map data © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors</a>'
|
||||
});
|
||||
tileLayer.addTo(map);
|
||||
|
||||
// Search box:
|
||||
const searchProvider = new window.GeoSearch.OpenStreetMapProvider();
|
||||
const searchControl = new GeoSearch.GeoSearchControl({
|
||||
provider: searchProvider,
|
||||
style: 'button',
|
||||
updateMap: true,
|
||||
autoClose: true,
|
||||
showMarker: false,
|
||||
keepResult: true,
|
||||
autoComplete: false
|
||||
});
|
||||
map.addControl(searchControl);
|
||||
|
||||
let latlon;
|
||||
var marker;
|
||||
|
||||
map.on('click', function(e){
|
||||
console.log(e);
|
||||
if (map.hasLayer(marker)) {
|
||||
map.removeLayer(marker);
|
||||
}
|
||||
latlon = e.latlng;
|
||||
marker = new L.marker(e.latlng).addTo(map);
|
||||
document.getElementById("select").style.display="";
|
||||
});
|
||||
|
||||
document.getElementById("select").addEventListener("click", function() {
|
||||
let settings = {}; // {"lat":48.8566,"lon":2.3522,"location":"Paris"}
|
||||
settings.lat = latlon.lat;
|
||||
settings.lon = latlon.lng;
|
||||
settings.location = "custom";
|
||||
Util.showModal("Saving...");
|
||||
Util.writeStorage("mylocation.json", JSON.stringify(settings), ()=>{
|
||||
Util.hideModal();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -4,11 +4,12 @@
|
|||
"icon": "app.png",
|
||||
"type": "settings",
|
||||
"screenshots": [{"url":"screenshot_1.png"}],
|
||||
"version":"0.07",
|
||||
"description": "Sets and stores the lat and long of your preferred City or it can be set from the GPS. mylocation.json can be used by other apps that need your main location lat and lon. See README",
|
||||
"version":"0.08",
|
||||
"description": "Sets and stores the latitude and longitude of your preferred City. It can be set from GPS or webinterface. `mylocation.json` can be used by other apps that need your main location. See README for details.",
|
||||
"readme": "README.md",
|
||||
"tags": "tool,utility",
|
||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||
"custom": "custom.html","custom": "custom.html",
|
||||
"storage": [
|
||||
{"name":"mylocation.settings.js","url":"settings.js"}
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue