Android nearSphere需要一个贴图操作符
//Rahees是Parse.com for android中的一个类,我想从中获得geopoint g的最近位置列表。Rahees类的列名为“Locations” 我想通过与Rahees类的Location列中列出的地质点进行比较,从g中获得最近的地质点列表 //******************拉希斯班************************//Android nearSphere需要一个贴图操作符,android,parse-platform,geopoints,Android,Parse Platform,Geopoints,//Rahees是Parse.com for android中的一个类,我想从中获得geopoint g的最近位置列表。Rahees类的列名为“Locations” 我想通过与Rahees类的Location列中列出的地质点进行比较,从g中获得最近的地质点列表 //******************拉希斯班************************// @ParseClassName("Rahees") public class Rahees extends ParseObject {
@ParseClassName("Rahees")
public class Rahees extends ParseObject {
public Rahees()
{
super();
}
public String getDisplayName() {
return getString("displayName");
}
public void setDisplayName(String value) {
put("displayName", value);
}
public static ParseQuery<Rahees> getQuery() {
return ParseQuery.getQuery(Rahees.class);
}
}
public class MainActivity extends AppCompatActivity {
ParseGeoPoint g;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ParseUser cuser = ParseUser.getCurrentUser();
Rahees haila = new Rahees();
haila.setDisplayName("Rahim");
}
//button for Logging out of system
public void logout(View view)
{
ParseUser.logOut();
Intent intent = new Intent(MainActivity.this, SignUp_Login.class);
startActivity(intent);
}
//Button for going to Map Masti class, it is this button which triggers to compare the geopoint g with the geopoints in the server
public void go_to_maps(View view)
{
Intent intent = new Intent(MainActivity.this, Map_Masti.class);
startActivity(intent);
}
}
public class Map_Masti extends FragmentActivity {
ParseGeoPoint g;
private TextView textView;
private SupportMapFragment mapFragment;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_masti);
textView = (TextView)findViewById(R.id.text);
mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_fragment);
//Query to get the geopoint g from server
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.getInBackground("ccm3xKMmr4", new GetCallback<ParseUser>() {
public void done(ParseUser object, ParseException e) {
if (e == null) {
g = (ParseGeoPoint) object.get("user_Location");
Log.d("mohit", g + "");
} else {
// something went wrong
Log.d("mohit", e + " ");
}
}
});
//****************************MapMasti类*****************************//
@ParseClassName("Rahees")
public class Rahees extends ParseObject {
public Rahees()
{
super();
}
public String getDisplayName() {
return getString("displayName");
}
public void setDisplayName(String value) {
put("displayName", value);
}
public static ParseQuery<Rahees> getQuery() {
return ParseQuery.getQuery(Rahees.class);
}
}
public class MainActivity extends AppCompatActivity {
ParseGeoPoint g;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ParseUser cuser = ParseUser.getCurrentUser();
Rahees haila = new Rahees();
haila.setDisplayName("Rahim");
}
//button for Logging out of system
public void logout(View view)
{
ParseUser.logOut();
Intent intent = new Intent(MainActivity.this, SignUp_Login.class);
startActivity(intent);
}
//Button for going to Map Masti class, it is this button which triggers to compare the geopoint g with the geopoints in the server
public void go_to_maps(View view)
{
Intent intent = new Intent(MainActivity.this, Map_Masti.class);
startActivity(intent);
}
}
public class Map_Masti extends FragmentActivity {
ParseGeoPoint g;
private TextView textView;
private SupportMapFragment mapFragment;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_masti);
textView = (TextView)findViewById(R.id.text);
mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_fragment);
//Query to get the geopoint g from server
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.getInBackground("ccm3xKMmr4", new GetCallback<ParseUser>() {
public void done(ParseUser object, ParseException e) {
if (e == null) {
g = (ParseGeoPoint) object.get("user_Location");
Log.d("mohit", g + "");
} else {
// something went wrong
Log.d("mohit", e + " ");
}
}
});
公共类映射\u Masti扩展了碎片活动{
地理点g;
私有文本视图文本视图;
私有支持mapFragment mapFragment;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.map_masti);
textView=(textView)findViewById(R.id.text);
mapFragment=(SupportMapFragment)getSupportFragmentManager();
//查询以从服务器获取地理点g
ParseQuery=ParseUser.getQuery();
getInBackground(“ccm3xKMmr4”,新的GetCallback(){
public void done(ParseUser对象,parsee异常){
如果(e==null){
g=(ParseGeoPoint)object.get(“用户位置”);
Log.d(“莫希特”,g+);
}否则{
//出了点问题
Log.d(“莫希特”,e+);
}
}
});
//用于比较对象“Rahees”和列“Locations”中哪些地理点靠近地理定位“g”的查询
ParseQuery mapQuery1=Rahees.getQuery();
地图1.流量计(“位置”,g,6000);
mapQuery1.setLimit(3);
mapQuery1.findInBackground(新的FindCallback(){
@凌驾
公共void done(列出对象,parsee异常){
//处理结果
如果(e==null){//****这就是异常错误出现的地方,它不会进入if语句****
对于(int i=0;i
下面是我从其他部分得到的错误
01-10 12:27:38.655 4348-4348/?D/错误:com.parse.ParseRequest$ParseRequestException:$nearSphere需要一个映射操作符
我可以从解析中检索g的值,g的日志输出为:
ParseGeoPoint[40.000000,30.000000]
请帮助您应该在得到第一个查询的结果后才进行第二次查询,因为
g
为null
直到将通过回调初始化
更新:
public class Map_Masti extends FragmentActivity {
ParseGeoPoint g;
private SupportMapFragment mapFragment;
private TextView textView;
private void getG() {
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.getInBackground("ccm3xKMmr4", new GetCallback<ParseUser>() {
public void done(ParseUser object, ParseException e) {
if (e == null) {
g = (ParseGeoPoint) object.get("user_Location");
Log.d("mohit", g + "");
getLocations();
} else {
// something went wrong
Log.d("mohit", e + " ");
}
}
});
}
private void getLocations() {
ParseQuery<Rahees> mapQuery1 = Rahees.getQuery();
mapQuery1.whereWithinKilometers("Locations", g, 6000);
mapQuery1.setLimit(3);
mapQuery1.findInBackground(new FindCallback<Rahees>() {
@Override
public void done(List<Rahees> objects, ParseException e) {
// Handle the results
if (e == null) {//****this is where the exception error comes, it doesn't goes inside if statement****
for (int i = 0; i < objects.size(); i++) {
Log.d("mohit", "2" + objects.get(i).get("Locations"));
}
} else {
Log.d("mohit", "" + e);
}
}
});
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_masti);
textView = (TextView) findViewById(R.id.text);
mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_fragment);
getG();
}
}
公共类映射\u Masti扩展了碎片活动{
地理点g;
私有支持mapFragment mapFragment;
私有文本视图文本视图;
私有void getG(){
ParseQuery=ParseUser.getQuery();
getInBackground(“ccm3xKMmr4”,新的GetCallback(){
public void done(ParseUser对象,parsee异常){
如果(e==null){
g=(ParseGeoPoint)object.get(“用户位置”);
Log.d(“莫希特”,g+);
getLocations();
}否则{
//出了点问题
Log.d(“莫希特”,e+);
}
}
});
}
私有void getLocations(){
ParseQuery mapQuery1=Rahees.getQuery();
地图1.流量计(“位置”,g,6000);
mapQuery1.setLimit(3);
mapQuery1.findInBackground(新的FindCallback(){
@凌驾
公共void done(列出对象,parsee异常){
//处理结果
如果(e==null){//****这就是异常错误出现的地方,它不会进入if语句中****
对于(int i=0;i
您应该在得到第一个查询的结果之后才进行第二个查询,因为g
是null
直到将通过回调初始化
更新:
public class Map_Masti extends FragmentActivity {
ParseGeoPoint g;
private SupportMapFragment mapFragment;
private TextView textView;
private void getG() {
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.getInBackground("ccm3xKMmr4", new GetCallback<ParseUser>() {
public void done(ParseUser object, ParseException e) {
if (e == null) {
g = (ParseGeoPoint) object.get("user_Location");
Log.d("mohit", g + "");
getLocations();
} else {
// something went wrong
Log.d("mohit", e + " ");
}
}
});
}
private void getLocations() {
ParseQuery<Rahees> mapQuery1 = Rahees.getQuery();
mapQuery1.whereWithinKilometers("Locations", g, 6000);
mapQuery1.setLimit(3);
mapQuery1.findInBackground(new FindCallback<Rahees>() {
@Override
public void done(List<Rahees> objects, ParseException e) {
// Handle the results
if (e == null) {//****this is where the exception error comes, it doesn't goes inside if statement****
for (int i = 0; i < objects.size(); i++) {
Log.d("mohit", "2" + objects.get(i).get("Locations"));
}
} else {
Log.d("mohit", "" + e);
}
}
});
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_masti);
textView = (TextView) findViewById(R.id.text);
mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_fragment);
getG();
}
}
公共类映射\u Masti扩展了碎片活动{
地理点g;
私有支持mapFragment mapFragment;
私有文本视图文本视图;
私有void getG(){
ParseQuery=ParseUser.getQuery();
getInBackground(“ccm3xKMmr4”,新的GetCallback(){
public void done(ParseUser对象,parsee异常){
如果(e==null){
g=(ParseGeoPoint)object.get(“用户位置”);
Log.d(“莫希特”,g+);
getLocations();
}否则{
//出了点问题
Log.d(“莫希特”,e+);
}
}
});
}
私有void getLocations(){
ParseQuery mapQuery1=Rahees.getQuery();
地图1.流量计(“位置”,g,6000);
mapQuery1.setLimit(3);
mapQuery1.findInBackground(新的FindCallback(){
@凌驾
公共void done(列出对象,parsee异常){
//处理结果
如果(e==null){//****这就是异常错误出现的地方,它不会进入if语句中****