mirror of https://github.com/espruino/BangleApps
openstreetmap 0.11: Add slight offset to OSM data to align it properly
+ Fix alignment of satellite info text (fix #984)pull/1017/head
parent
ce9f3fb521
commit
16b92b613f
|
@ -1955,11 +1955,12 @@
|
||||||
"id": "openstmap",
|
"id": "openstmap",
|
||||||
"name": "OpenStreetMap",
|
"name": "OpenStreetMap",
|
||||||
"shortName": "OpenStMap",
|
"shortName": "OpenStMap",
|
||||||
"version": "0.10",
|
"version": "0.11",
|
||||||
"description": "[BETA] Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are",
|
"description": "Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are. Once installed this also adds map functionality to `GPS Recorder` and `Recorder` apps",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "outdoors,gps",
|
"tags": "outdoors,gps,osm",
|
||||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||||
|
"screenshots": [{"url":"screenshot.png"}],
|
||||||
"custom": "custom.html",
|
"custom": "custom.html",
|
||||||
"customConnect": true,
|
"customConnect": true,
|
||||||
"storage": [
|
"storage": [
|
||||||
|
|
|
@ -8,3 +8,5 @@
|
||||||
0.08: Update for drag event refactor
|
0.08: Update for drag event refactor
|
||||||
0.09: Use current theme cols when drawing GPS info
|
0.09: Use current theme cols when drawing GPS info
|
||||||
0.10: Improve scale factor calculation to fix scaling issues (#984)
|
0.10: Improve scale factor calculation to fix scaling issues (#984)
|
||||||
|
0.11: Add slight offset to OSM data to align it properly (fix #984)
|
||||||
|
Fix alignment of satellite info text
|
||||||
|
|
|
@ -25,11 +25,11 @@ function drawMarker() {
|
||||||
var fix;
|
var fix;
|
||||||
Bangle.on('GPS',function(f) {
|
Bangle.on('GPS',function(f) {
|
||||||
fix=f;
|
fix=f;
|
||||||
g.reset().clearRect(0,y1,240,y1+8).setFont("6x8").setFontAlign(0,0);
|
g.reset().clearRect(0,y1,g.getWidth()-1,y1+8).setFont("6x8").setFontAlign(0,0);
|
||||||
var txt = fix.satellites+" satellites";
|
var txt = fix.satellites+" satellites";
|
||||||
if (!fix.fix)
|
if (!fix.fix)
|
||||||
txt += " - NO FIX";
|
txt += " - NO FIX";
|
||||||
g.drawString(txt,120,y1 + 4);
|
g.drawString(txt,g.getWidth()/2,y1 + 4);
|
||||||
drawMarker();
|
drawMarker();
|
||||||
});
|
});
|
||||||
Bangle.setGPSPower(1, "app");
|
Bangle.setGPSPower(1, "app");
|
||||||
|
|
|
@ -132,8 +132,10 @@ TODO:
|
||||||
var zoom = map.getZoom();
|
var zoom = map.getZoom();
|
||||||
var centerlatlon = map.getBounds().getCenter();
|
var centerlatlon = map.getBounds().getCenter();
|
||||||
var center = map.project(centerlatlon, zoom).divideBy(OSMTILESIZE);
|
var center = map.project(centerlatlon, zoom).divideBy(OSMTILESIZE);
|
||||||
var ox = Math.round((center.x - Math.floor(center.x)) * OSMTILESIZE);
|
// Reason for 16px adjustment below not 100% known, but it seems to
|
||||||
var oy = Math.round((center.y - Math.floor(center.y)) * OSMTILESIZE);
|
// align everything perfectly: https://github.com/espruino/BangleApps/issues/984
|
||||||
|
var ox = Math.round((center.x - Math.floor(center.x)) * OSMTILESIZE) + 16;
|
||||||
|
var oy = Math.round((center.y - Math.floor(center.y)) * OSMTILESIZE) + 16;
|
||||||
center = center.floor(); // make sure we're in the middle of a tile
|
center = center.floor(); // make sure we're in the middle of a tile
|
||||||
// JS version of Bangle.js's projection
|
// JS version of Bangle.js's projection
|
||||||
function bproject(lat, lon) {
|
function bproject(lat, lon) {
|
||||||
|
@ -155,8 +157,15 @@ TODO:
|
||||||
var bd = bproject(pd.lat, pd.lng)
|
var bd = bproject(pd.lat, pd.lng)
|
||||||
var scale = bc.distanceTo(bd);
|
var scale = bc.distanceTo(bd);
|
||||||
|
|
||||||
var tileGetters = [];
|
// test
|
||||||
|
/*var p = bproject(centerlatlon.lat, centerlatlon.lng);
|
||||||
|
var q = bproject(mylat, mylon);
|
||||||
|
var testPt = {
|
||||||
|
x : (q.x-p.x)/scale + (MAPSIZE/2),
|
||||||
|
y : (MAPSIZE/2) - (q.y-p.y)/scale
|
||||||
|
};*/
|
||||||
|
|
||||||
|
var tileGetters = [];
|
||||||
// Render everything to a canvas...
|
// Render everything to a canvas...
|
||||||
var canvas = document.getElementById("maptiles");
|
var canvas = document.getElementById("maptiles");
|
||||||
canvas.style.display="";
|
canvas.style.display="";
|
||||||
|
@ -173,6 +182,11 @@ TODO:
|
||||||
tileGetters.push(new Promise(function(resolve,reject) {
|
tileGetters.push(new Promise(function(resolve,reject) {
|
||||||
img.onload = function(){
|
img.onload = function(){
|
||||||
ctx.drawImage(img,i*OSMTILESIZE - ox, j*OSMTILESIZE - oy);
|
ctx.drawImage(img,i*OSMTILESIZE - ox, j*OSMTILESIZE - oy);
|
||||||
|
/*if (testPt) {
|
||||||
|
ctx.fillStyle="green";
|
||||||
|
ctx.fillRect(testPt.x-1, testPt.y-5, 3,10);
|
||||||
|
ctx.fillRect(testPt.x-5, testPt.y-1, 10,3);
|
||||||
|
}*/
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
Loading…
Reference in New Issue