How to use the coordinates function from chance

Find comprehensive JavaScript chance.coordinates code examples handpicked from public code repositorys.

5
6
7
8
9
10
11
12
13
14
15


/**
 * $coordinates operator, returns a 2-element array of [longitude, latitude]
 * coordinates.
 *
 * Note: this operator overwrites the chance.coordinates() operator, as it
 * returns a string in "latitude, longitude" format, which is not compatible
 * to MongoDBs geolocation indexes.
 *
 * @example Creates random coordinate pairs
fork icon21
star icon117
watch icon0

10
11
12
13
14
15
16
17
18
19
spec.label = 'coords';   // usually plural
spec.list = [];

for( var i = 0; i < count; i++ ) {

    let coord = chance.coordinates().split(",")

    spec.list.push( { 
        type: spec.label, 
        latitude: parseFloat(coord[0]),
fork icon0
star icon1
watch icon0

12
13
14
15
16
17
18
19
20
21
22
23
let _getCountry = function() {
    return Chance.country({ full: true });
}


let _getCoordinates = function () {
    return Chance.coordinates();
}


let _getZipCode = function () {
    return Chance.zip();
fork icon0
star icon0
watch icon0