1 year ago
#163646
Taki
The radius is bigger than 8587.0 and hence we'll use that value
I have an uber app where i need to query the customer location , i set my initial radius to 1 , and the application was working fine , after sometime without any changes made of my part , it started throwing this error which i will show below , any help is appreciated Thank you
Error :
The radius is bigger than 8587.0 and hence we'll use that value
Code:
private fun getNearByDrivers(){
val geoFire = GeoFire(driverAvailableRef)
val geoQuery = geoFire.queryAtLocation(GeoLocation(customPickUpLocation.latitude,customPickUpLocation.longitude),radius)
geoQuery.removeAllListeners()
geoQuery.addGeoQueryEventListener(object : GeoQueryEventListener{
override fun onKeyEntered(key: String?, location: GeoLocation?) {
if(!isDriverFound){
isDriverFound = true
driverID = key!!
// Get Driver Info
driverInfoReference = FirebaseDatabase.getInstance(Utils.REAL_TIME_URL).reference.child("Users")
.child("Drivers").child(driverID)
val driverMap = hashMapOf<String,Any>()
driverMap["CustomerRideId"] = firebaseAuth.currentUser!!.uid
driverInfoReference.updateChildren(driverMap)
binding.callCar.text = "Getting Driver Location"
getCurrentlyWorkingDrivers()
}
}
override fun onKeyExited(key: String?) { }
override fun onKeyMoved(key: String?, location: GeoLocation?) { }
override fun onGeoQueryReady() {
// This will keep looking for new drivers
if(!isDriverFound){
radius += 1
getNearByDrivers()
}
}
override fun onGeoQueryError(error: DatabaseError?) {
Toast.makeText(this@ClientMapsActivity,"Error " +
error!!.message,Toast.LENGTH_LONG)
.show()
}
})
}
Error Screenshot :
Driver Location:
Customer Location :
PS : I have omitted the location numbers before "." , but they are the same
android
kotlin
firebase-realtime-database
geofire
0 Answers
Your Answer