xxxxxxxxxx
26
// must be in HTTPS
function setup() {
createCanvas(windowWidth, windowHeight);
console.log('starting');
noStroke();
// get position once
if (!navigator.geolocation) {
alert("navigator.geolocation is not available");
}
navigator.geolocation.getCurrentPosition(setPos);
}
function setPos(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
background(0);
fill(255);
textSize(32);
text("Current position: " + nf(lat,2,5) + " " + nf(lng,2,5), 10, height/2);
var myMap = "https://www.google.com/maps/@"+lat+","+lng+",3000m/data=!3m1!1e3";
text(myMap,10, height/2+40);
print(myMap);
createA(myMap,"map","_blank");
}