Rakesh Mohan Rakesh Mohan - 1 year ago 125
iOS Question

How to convert Latitude and longitude to float value in swift

I have tried the below code :
but it shows error cannot convert value of type float to expected argument type CLLocation degrees(aka Double)

let lat = self.mallData.valueForKey("lat") as! Float
let lon = self.mallData.valueForKey("lon")

let mapLocation : CLLocationCoordinate2D = CLLocationCoordinate2DMake(lat, lon)

Answer Source

The CLLocationCoordinate2DMake supports Double values. But you are converting lat and lon to Float.

Try converting Lat and Lon to Double.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download