Android Question catch Latitude and Longitude empty value

qey

Member
Hello everyone. I have two different location A and B. For A it automatically set with current location and for B user need to insert the location. But whenever the user did not put the location which is the lat and long will become an empty string the deliverycharges will become 0. So right now i want to check

if lat and long = Null Then
Then deliverycharges = 0$ End If


but right now it cannot make the if else condition because lat and long is not a boolean. So any idea on how to make a condition to check the value of latlong ?
 

emexes

Expert
Licensed User
any idea on how to make a condition to check the value of latlong ?

Maybe something like:

B4X:
if IsNumber(Lat) and IsNumber(Lon) then
    if Lat = 0 and Lon = 0 then
        log("Welcome to Null Island!")
    else
        log("location looks good")
    end if
else
    log("invalid or unspecified location (so delivery is free)")
end

or if you're happier without the Null Island reference, then:

B4X:
if IsNumber(Lat) and IsNumber(Lon) and (Lat <> 0 or Lon <> 0) then
    log("location looks good")
else
    log("invalid or unspecified location (so delivery is free)")
end
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
How do you read the lat and long values.
But whenever the user did not put the location which is the lat and long will become an empty string the deliverycharges will become 0.
Where is the conversion from an empty string to zero done.
When you try to convert an empty string to a number you get an error.
So you should check valid lat and long values there.
I would also check if the distance is realistic or not, there is probably a max range of action value which could be checked.
 
Upvote 0
Top