Commit 8927dd42 authored by Michael Ochmann's avatar Michael Ochmann
Browse files

changed geolocation access

parent 40ed77bb
......@@ -22,6 +22,20 @@ class HeightMapViewController extends UIViewController {
this.translated = 0;
this.isCapturing = false;
this.addSubview(new MapController("#osm", this.model));
navigator.geolocation.watchPosition(position => {
if (!this.isCapturing || position.coords.accuracy > 10)
return;
this.addPoint(new GeoPoint(
position.coords.latitude,
position.coords.longitude,
position.coords.altitude
), error => console.log(error), {
timeout : 0,
enableHighAccuracy : true,
maximumAge : Infinity
});
});
}
addPoint(geoPoint) {
......@@ -35,18 +49,6 @@ class HeightMapViewController extends UIViewController {
}
capture() {
navigator.geolocation.getCurrentPosition(position => {
if (position.coords.accuracy)
this.addPoint(new GeoPoint(
position.coords.latitude,
position.coords.longitude,
position.coords.altitude
), error => console.log(error), {
timeout : 0,
enableHighAccuracy : true,
maximumAge : Infinity
});
});
/* this.addPoint(new GeoPoint(
Std.Random(136, 150),
Std.Random(60, 150),
......@@ -120,14 +122,14 @@ class HeightMapViewController extends UIViewController {
});
this.drawHeightMap();
if (!this.isCapturing)
/* if (!this.isCapturing)
return;
this.capture();
/* capturing new points */
/!* capturing new points *!/
HeightMapViewController.MAINLOOP = setInterval(() => {
this.capture();
}, 1000);
}, 1000);*/
}
drawHeightMap() {
......@@ -147,12 +149,14 @@ class HeightMapViewController extends UIViewController {
ctx.fillStyle = "#029BE8";
ctx.font = "15px Arial";
ctx.textAlign = "left";
let num = 0;
for (let point of this.model.points) {
let ordinateVal = Std.Map(point.altitude, min, this.model.max, 0, height * 0.95);
ctx.lineTo(x, height - ordinateVal);
x+=40;
if (point.altitude)
if (point.altitude && num % 2 === 0)
ctx.fillText(point.altitude.toFixed(2), x - 50, height - ordinateVal - 16);
num++;
}
ctx.lineTo(x - 40, height);
ctx.lineTo(0, height);
......@@ -168,6 +172,7 @@ class HeightMapViewController extends UIViewController {
/* drawing the text, not affected by translation through scrolling */
ctx.save();
ctx.globalAlpha = 1;
ctx.setTransform(1,0,0,1,0,0);
ctx.fillStyle = "#555";
ctx.font = "bold 23px Arial";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment