I am currently using html 5’s geo location feature. Everything works and its a good feature. However, as counter intuitive this may sound, I want the location which it obtains to be less accurate.
At the moment, it is getting my exact location, and, due to data privacy, I dont want this. Is there a way to make it less accurate ?
I am currently trying to create a function called getRandomGeoValue, shown below:
function getRandomGeoValue(geoValue)
{
}
The function takes a geo value (either latitude or longitude) and returns an random inaccurate geo value. I am trying to use Javascripts Math.random() function, but the result is way too inaccurate.
Ideally, the inaccuracy would be around 17 miles.
You could take the current location (presumably latitude and longitude) and apply one of several transformations to it:
If your lat/long values are in degrees, then you can round it to the nearest N miles with this function:
This function returns an object with the new rounded latitude and longitude as properties.
Example usage: