Hello!
I’m trying to convert a series of latitude and longitude points to show up as a polygon at scale in p5.js
for example starting with the following series of lat/lon points
44.964782, -93.276922
44.964125, -93.266912
44.918733, -93.241098
44.924925, -93.331771
I’d like to somehow get an output of a rendering of a polygon that takes up the whole canvas.
so something like:
function setup() {
createCanvas(400, 400);
}
function draw() {
console.log(mouseX,mouseY)
background(220);
beginShape()
vertex(91,69)
vertex(283,81)
vertex(285,307)
vertex(107,238)
vertex(81,190)
endShape(CLOSE)
}
Here is something that I tried, but it’s wayyyyy tooo small.
function setup() {
createCanvas(400, 400);
background(220);
beginShape()
let first = ll2c( 44.964782, -93.276922)
console.log(first)
vertex(first.x,first.y)
let second = ll2c(44.964125, -93.266912)
console.log(second)
vertex(second.x,second.y)
let third = ll2c(44.918733, -93.241098)
vertex(third.x,third.y)
let forth = ll2c(44.924925, -93.331771)
vertex(forth.x,forth.y)
endShape()
}
function draw() { }
function ll2c(lat, lon){
let latOut = map(lat, -90, 90, 0, 400);
let lonOut = map(lon, -180,180,0,400);
return createVector(latOut, lonOut);
}