无法从自定义查询中获取对象数据Back& - Backand.com - 未定义

时间:2016-07-20 15:46:13

标签: javascript angularjs ionic-framework backand

这是我从后端服务获取对象的get方法

// LocationService add, update, delete, etc
.service('LocationService', function ($http, Backand) {

// Initiation the opject 
var baseUrl = '/1/objects/';
var objectName = 'location/';
var query ='/1/query/data/';

function getUrl() {
 return Backand.getApiUrl() + baseUrl + objectName;
}

function getUrlForId(id) {
 return getUrl() + id;
}

getLocations = function (id) {  

    var url = Backand.getApiUrl() + query + 'getLocationbyUserName?' + 'parameters=%7B%22Username%22:%22habibi%22%7D';
    //var url = 'https://api.backand.com/1/query/data/getLocationbyUserName?parameters=%7B%22Username%22:%22ha%22%7D';
    //var url = getUrlForId(id);
    return $http.get(url);
};

添加我的控制器

 LocationService.getLocations('2').then(function (result) {
                $scope.location = result.data;
                alert($scope.location.latitude);
                friendLatitude = $scope.location.latitude;
                friendLongtitude = $scope.location.longtitude;
 },function(error){
                console.log("LocationService cannot get friend location");
                    }); 

但是,我从$ scope.location.latitude得到了结果未定义

1 个答案:

答案 0 :(得分:0)

我想如果你提醒结果数据,你会看到只有租船人,原因就是从对象获取Geo位置和从查询中获取Geo位置之间的不同响应。您需要做的是操纵查询以返回从该对象解析的纬度和经度

SELECT CONCAT(X(`lat_long`), ',', Y(`lat_long`))  as origin
FROM `garages` 
WHERE (ST_Distance .........