解析地理查询始终为空 [英] Parse geo-queries always empty

查看:17
本文介绍了解析地理查询始终为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试让 Parse 的地理查询系统工作.在我的数据浏览器上,我安装了一个 geo-point 类型的关键位置",其中设置了一个纬度为 30.27263636013176 和经度为 -97.75766807716373 的地理点.

Im currently trying to get Parse's geo-query system to work. On my data browser, I have an installation with a key "location" of type geo-point that has a geo-point with latitude 30.27263636013176 and longitude -97.75766807716373 set in it.

但是,如果我尝试使用以下代码进行查询,我总是得到结果":[].

However, if I try to query with the following code, I always get "results":[].

curl -X GET  
-H "X-Parse-Application-Id: myAppKey"  
-H "X-Parse-REST-API-Key: myAPIKey"  
-G  --data-urlencode 'limit=10' 
--data-urlencode 'where={
"location": {
  "$nearSphere": {
    "__type": "GeoPoint",
    "latitude": 30,
    "longitude": -97
  }
}
}' 
https://api.parse.com/1/classes/PlaceObject

注意查询运行成功;没有错误.问题是我应该出现的安装.

Note that the query is running successfully; there are no errors. The problem is the installation I have should come up.

如果我将查询中的纬度和经度更改为与数据浏览器中显示的纬度和经度完全一致,我仍然得到空结果.这是什么原因?是否无法查询某个点附近的设备安装?

If I change the latitude and longitude in the query to exactly the latitude and longitude shown in the data browser, I still get empty results. What is the reason for this? Is it not possible to query for device installations near a point?

推荐答案

Installation 类无法从客户端查询,这是有充分理由的.Installation 类中存储了太多敏感信息,无法从客户端进行查询.

The Installation class can't be queried from the client, for good reason. Too much sensitive information is stored in the Installation class to allow querying from a client.

location 属性移动到另一个您可以查询的类,或在云函数中查询它.

Either move the location property to another class you can query, or query it in a Cloud Function.

如果您使用 Parse.Cloud.useMasterKey();,您可以在 Cloud Code 中查询它,但我强烈建议使用不同的类来存储 location.

You can query it in Cloud Code if you use Parse.Cloud.useMasterKey();, though I strongly recommend using a different class to store the location.

这篇关于解析地理查询始终为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆