Support Topics Documentation Slack YouTube Blog

JavaScript async callback for geo radius search missing distance property


(Simon Nishi McCorkindale) #1

The following code will give a distance property in the result when called with the sync method, but not the async method.

Code:






var point = { 

   latitude: 21.306944, 

   longitude: -157.858333, 

   categories:["Coffee", "City"], 

   metadata: { 

      "Name":"Starbucks", 

      "City": "Honolulu", 

      "Parking":true, 

      "updated": Date.now() 

   } 

}; 

Backendless.Geo.addPoint(point); 

var query = new BackendlessGeoQuery(); 

query.categories = ['Coffee', 'City']; 

query.includeMetadata = true; 

query.latitude = 21.30; 

query.longitude = -157.858333; 

query.radius = 50; 

query.units = Backendless.Geo.UNITS.KILOMETERS; 

//query.condition = "updated > " + updated; 

var result = Backendless.Geo.find(query); 

console.log("sync result:");

console.log(result);

var callback = new Backendless.Async(

    function(result)

    {

        console.log("async result:");

        console.log(result);        

    },

    function(error) {

        console.error(error.message);

    });

var result = Backendless.Geo.find(query, callback); 


Result:


sync result:
ja.js:54 Object {data: Array[5], totalObjects: 5, offset: 0}data: Array[5]0: Object___class: "GeoPoint"categories: Array[2]distance: 0.773latitude: 21.306944longitude: -157.858333metadata: ObjectobjectId: "12706831-6840-AED2-FF68-D01DD4EB5D00"__proto__: Object1: Object2: Object3: Object4: Objectlength: 5__proto__: Array[0]offset: 0totalObjects: 5__proto__: Object
ja.js:58 async result:
ja.js:59 Object {data: Array[5], totalObjects: 5, offset: 0}data: Array[5]0: GeoPoint___class: "GeoPoint"categories: Array[2]latitude: 21.306944longitude: -157.858333metadata: ObjectobjectId: "12706831-6840-AED2-FF68-D01DD4EB5D00"__proto__: GeoPoint1: GeoPoint2: GeoPoint3: GeoPoint4: GeoPointlength: 5__proto__: Array[0]offset: 0totalObjects: 5__proto__: Object