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

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

问题描述

我目前正在尝试使Parse的地理查询系统正常工作.在我的数据浏览器上,我安装了一个带有"geopoint"类型的关键位置"的安装,其中安装了一个经度为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属性移到您可以查询的另一个类中,或者在Cloud Function中查询它.

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天全站免登陆