невозможно извлечь несколько местоположений из геофайра, сохраненного методом pu sh - PullRequest
0 голосов
/ 13 января 2020

Я сохранил некоторые координаты местоположения в geofire с помощью метода pu sh

 geoFire = new GeoFire(databaseReference.child("locations").child("geofire"));
                             key = databaseReference.push().getKey();

                            geoFire.setLocation(key, new GeoLocation(usersloction.getLat(), usersloction.getLng()), new GeoFire.CompletionListener() {
                                @Override
                                public void onComplete(String key, DatabaseError error) {
                                    if (error != null) {
                                        Toast.makeText(AddActivity.this, "Oops , something went wrong in saving the location:(", Toast.LENGTH_SHORT).show();
                                    } else {
                                        clear();
                                        Toast.makeText(AddActivity.this, "location saved successfully :)", Toast.LENGTH_SHORT).show();
                                    }
                                }
                            });

и пытаюсь получить список следующим методом

 GeoFire geoFire = new GeoFire(databaseReference.child("locations").child("geofire"));

    GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(locations.getLat(),locations.getLng()), 10);
    geoQuery.addGeoQueryEventListener(new GeoQueryEventListener() {
        @Override
        public void onKeyEntered(String key, GeoLocation location) {
            LatLng latLng = new LatLng(location.latitude,location.longitude);
            mMap.addMarker(new MarkerOptions().position(latLng));


            Toast.makeText(MainActivity.this, "onkeyentered" , Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onKeyExited(String key) {
            System.out.println(String.format("Key %s is no longer in the search area", key));
        }

        @Override
        public void onKeyMoved(String key, GeoLocation location) {
            System.out.println(String.format("Key %s moved within the search area to [%f,%f]", key, location.latitude, location.longitude));
        }

        @Override
        public void onGeoQueryReady() {
            System.out.println("All initial data has been loaded and events have been fired!");

            Toast.makeText(MainActivity.this, "onGeoqueryReady" , Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onGeoQueryError(DatabaseError error) {
            Toast.makeText(MainActivity.this, "something went wrong", Toast.LENGTH_SHORT).show();
            System.err.println("There was an error with this query: " + error);
        }
    });

, но это не показывает маркер, я делаю что-то не так? он успешно сохраняет местоположения в базе данных, но не извлекает местоположение, помогите, плз ...

...