generateRandomPoints(center, radius, count)
Generates random geolocation objects, in the form of plain-old javascript objects.
Usage
Install it with npm
or yarn
and use as a normal module
Installing
$ npm install generate-random-points --save
Consider this code:
'use strict' const generateRandomPoint generateRandomPoints } = const options = centerPosition: lat: 2423 lng: 2312 radius: 1000 count: 2 let listOfPoints = let singlePoint = return listOfPoints singlePoint
It should produce something like this:
API
function generateRandomPoints (center, radius, count)
/**
* Generates number of random geolocation points given a center and a radius.
*
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoint (center, radius)
/**
* Generates number of random geolocation points given a center and a radius.
*
* Reference URL: http://goo.gl/KWcPE.
* @param {Object} center A JS object with 'latitude' and 'longitude' attributes.
* @param {number} radius Radius in meters.
* @return {Object} The generated random points as JS object with latitude and longitude attributes.
*/
Credits
All those involved in this stackoverflow page: http://goo.gl/KWcPE @mkhatib for publishing this snippet of code in this gist https://gist.github.com/mkhatib/5641004