// Rahees является классом в Parse.com для android, откуда я хочу получить список ближайшего местоположения из геоинформации. G.Rahees класс имеет название столбца «Locations».nearSphere нужен оператор карты
Я хочу, чтобы получить список ближайших geopoints от г, сравнивая его с geopoints, перечисленных в колонке Location класса Rahees
// **************** ** Класс Раши ************************ //
@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);
}
}
// ***** *********************** MapMasti Class ************************* **** //
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 + " ");
}
}
});
// запрос для сравнения, который geopoints в объекте «Rahees» с колонкой «Места» находятся рядом с geopoing «г»
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);
}
}
});
}
}
Ниже ошибка я получаю, от ELSE часть
01-10 12: 27: 38.655 4348-4348 /? D/ошибка: com.parse.ParseRequest $ ParseRequestException: $ nearSphere нужен оператор карты
Я могу retrive значение г из разбора выход Вход для г является: ParseGeoPoint [40.000000,30.000000]
Пожалуйста, помогите
просьба представить декларацию 'G' переменной – gio
Пожалуйста, проверьте отредактированный вопрос @ gio.Thanks – learner
Просьба предоставить полный код класса, чтобы увидеть отношения между полями и Calss – gio