I want to generate a random coordinate that would display anywhere on the map. I've seen these two posts:
Generating random lat/long coordinates
And using this post for the JavaScript code: https://stackoverflow.com/questions/69221354/how-to-generate-random-longitude-and-latitude
And came up with the following:
function generateRandomLonLat() {
return [Math.floor(Math.random() * 360) - 180, Math.round(Math.acos(2 * Math.random() - 1) * 180 / Math.PI) - 90];
}
But it also generates non-valid coordinates that are outside of the map.
Why?