Exemplo n.º 1
0
const Tile38Client = require('tile38-client');
const client = new Tile38Client();


// construct the geofence query
let query = client.intersectsQuery('fleet').detect('enter','exit').bounds(33.462, -112.268, 33.491, -112.245);
// start the live geofence
let fence = query.executeFence((err, results) => {
    // this callback will be called multiple times
    if (err) {
        console.log("error: " + err);
    } else {
        console.dir(results);
    }
});

// if you want to be notified when the connection gets closed
fence.onClose(() => {
    console.log("geofence was closed");
});

// after 20 seconds, close the geofence again.
setTimeout(() => {
    fence.close();
}, 20000);
Exemplo n.º 2
0
  }).catch(err => {
    console.error(err)
  })
}

// GET:
client.getPoint('people', 'person1').then(obj => {
  console.log(obj)
}).catch(err => {
  console.error(err)
})

client.getPoint('people', 'person2').then(obj => {
  console.log(obj)
}).catch(err => {
  console.error(err)
})

// SCAN:
const scan = client.scanQuery('people').nofields().points()
console.log(scan)

// NEARBY:
client.nearbyQuery('people').distance().point(21.007031, 105.828033, 1000)

// INTERSECT:
client.intersectsQuery('people').bounds(21.007031, 105.828033, 21.006696, 105.827534)

// WITHIN:
client.withinQuery('people').bounds(21.007031, 105.828033, 21.006696, 105.827534)