Problem is that I want to store customer latitude and longitude to find the distance between admin and customer, but if customer move then how I'll change the distance. Should I have to update again and again database with finding lat and long?
I want to list all customer Order by nearest one with distance from admin in flutter in admin app. Admin and customer two flutter mobile app.
Many apps have documents that are indexed by physical locations. For example, your app might allow users to browse stores near their current location.
Cloud Firestore only allows a single range clause per compound query, which means we can't perform geo queries by simply storing latitude and longitude as separate fields and querying a bounding box.
Solution: Geohashes
Geohash is a system for encoding a (latitude, longitude) pair into a single Base32 string. In the Geohash system the world is divided into a rectangular grid. Each character of a Geohash string specifies one of 32 subdivisions of the prefix hash. For example the Geohash abcd is one of 32 four-character hashes fully contained within the larger Geohash abc.
The longer the shared prefix between two hashes, the closer they are to each other. For example abcdef is closer to abcdeg than abcdff. However the converse is not true! Two areas may be very close to each other while having very different Geohashes:
Geohashes far apart
We can use Geohashes to store and query documents by position in Cloud Firestore with reasonable efficiency while only requiring a single indexed field.
Limitations Using Geohashes for querying locations gives us new capabilities, but comes with its own set of limitations:
False Positives - querying by Geohash is not exact, and you have to filter out false-positive results on the client side. These extra reads add cost and latency to your app. Edge Cases - this query method relies on estimating the distance between lines of longitude/latitude. The accuracy of this estimate decreases as points get closer to the North or South Pole which means Geohash queries have more false positives at extreme latitudes.