我尝试从Google Maps SDK中检索纬度和经度值,我正在使用它:
NSString *lati = [end_loc objectForKey:@"lat"];
NSString *longi = [end_loc objectForKey:@"lng"];
marker.position = CLLocationCoordinate2DMake(lati, longi);
但是在 marker.position 的行中我收到此错误:
Passing 'NSString *__strong' to parameter of incompatible type 'CLLocationDegrees' (aka 'double')
关于如何解决它的任何想法?
答案 0 :(得分:7)
那是因为CLLocationCoordinate2DMake希望CLLocationDegrees作为一种参数,并且你传递NSStrings(或者在end_lok中传递key lat / lon的内容)。
您可以尝试解决此问题:
NSString *lati = [end_loc objectForKey:@"lat"];
NSString *longi = [end_loc objectForKey:@"lng"];
marker.position = CLLocationCoordinate2DMake([lati doubleValue], [longi doubleValue]);