Reputation: 543
I am developing the application where the application has to detect which floor the user is on in a building.
I have tried using CLLocation (location.floor?.level
) but this value always returns nil.
Please suggest me if there is any other way to get floor level.
Upvotes: 4
Views: 2265
Reputation: 93191
TL, DR: unless your location is on the indoor mapping list, floor
will be nil.
While it's true that GPS doesn't work indoor, iOS has other tricks to determine users' location when they are inside buildings. You can still get the latitude, longitude and altitude of the user.
The real reason is your location doesn't support indoor mapping. The altitude is measured in meters above / below sea level. Not all cities, or even neighborhoods in the same city, are at the same sea level. Some buildings have taller floors than others. It requires extra work to get that information and Apple has not done that for your location.
Upvotes: 5