If by "based on" you mean given random number 0 ≤ i < map.len(), you want the i-th key, then I don't think there is a direct way.
If you need the key (as well as the element), then a workaround could be to maintain a copy of the keys in an Vec, for example. If you don't plan to mutate the collection after it is built, you can just perform this mapping once upfront, and then keep looking up the keys based on their index.
If you only need the values, or you need to mutate the collection, then another way would be to keep around a copy of the values instead, always push() when a new element is inserted, swap_remove() when one is deleted, and then pick from the values directly.
A third approach could be to design a two-level mapping where instead of storing the values directly in the BTreeMap, you store them in a Vec and you only store their indices in the BTreeMap. This still allows you to index into the Vec, and it will also allow you to access them by key.
Somebody has suggested me another approach which to me appears better, for some reason:
generate a new GUID and check which of the existing ones (keys) it's the closest to.
Then this begs a question: given a vector of GUIDs and a target GUID, how will I find which of the GUIDs in a vector is the closest to the the target one?
Depending on the performance characteristics you need, you might be able to just use BTreeMap's iter method along with the nth combinator. It won't be optimally fast, but it's an option if you only need to find a random value occasionally.
I think you would need lower level access to the data structures inside BTreeMap than what std currently offers to be able to use a strategy like that.