Tuesday 16 May 2017

Tile38 Near by query node call back function is not working

I'm building a small GEO application and it's using http://tile38.com/ and https://www.npmjs.com/package/tile38 node module. Everything working fine but I'm unable to get result from the NEARBY query from the node module. It looks like the call back function isn't working, I've spent lot of time but couldn't find a way out. What I want is get the result from the nearby query and assign to a variable.

Here is the code:

var Tile38 = require('tile38');

var client = new Tile38({host: 'localhost', port: 9851, debug: true });

// set a simple lat/lng coordinate
client.set('fleet', 'truck1', [33.5123, -112.2693])
// set with additional fields


client.nearbyQuery('fleet').distance().point(33.5123, -112.2693, 6000).execute((err, results) => {
    console.log("########");
    // this callback will be called multiple times
    if (err) {
        console.error("something went wrong! " + err);
    } else {
        console.log(results + "##########");
    }
});;

but when I try the following simple query it's working fine.

client.get('fleet', 'truck1').then(data => {
  console.log(data); // prints coordinates in geoJSON format 

}).catch(err => {
  console.log(err); // id not found  
});

ALSO when I try the RAW query in the tile38-cli it's working fine.

NEARBY fleet POINT 33.5123 -112.2693 6000

Any help would appreciated.

Thanks in advance.



via FR STAR

No comments:

Post a Comment