-4

How to get the latitude and longitude from firebase it stored like below screen shot

enter image description here

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
pooja
  • 7
  • 2

1 Answers1

0

Please refer below code for getting the values for lat and lng

FirebaseDatabase.getInstance().getReference().child("parkingSlots").child("compact").child("0").addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
            if (dataSnapshot != null && dataSnapshot.exists()) {
              try{
                float lng  =    Float.parseFloat(dataSnapshot.child("longitude").getValue().toString());
                 float lat  =    Float.parseFloat(dataSnapshot.child("latitude").getValue().toString());
            } catch(NumberFormatException e){
            }
        }
    }
}
SimpleCoder
  • 1,665
  • 1
  • 21
  • 34
  • thanks for your reply, if any possible way to get those values using model class? – pooja Oct 17 '18 at 07:09
  • use ModelClass modleClass = dataSnapshot.getValue(ModelClass .java); Where your ModelClass will have fields like longitude or latitude etc. – SimpleCoder Oct 18 '18 at 05:30