Get location name from Latitude & Longitude in iOS

前端 未结 12 1050
遥遥无期
遥遥无期 2020-11-28 07:30

I want to find current location name from latitude and longitude,

Here is my code snippet I tried but my log shows null value in all the places except in place

12条回答
  •  伪装坚强ぢ
    2020-11-28 07:51

    First of all, filter locations in didUpdateToLocation to prevent use cached or wrong locations for geocoding

    NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow];
    
    if (abs(locationAge) > 5.0) return;
    
    if (newLocation.horizontalAccuracy < 0) return;
    

    Also, try to move the reverseGeoCoding method away from didUpdateToLocation

提交回复
热议问题