0

我将地图点的纬度和经度值保存为我的数据库中的整数。

所以我的值是这样的:3454534353。但是使用时,我需要使用浮点数作为34.54534353。

我怎样才能进行这种转换?

这是我创建地图点的方法:

MapLocation *location = [[MapLocation alloc] init];  
location.title = [NSString stringWithString:[locations objectForKey:@"title"]];  
location.subtitle = [NSString stringWithString:[locations objectForKey:@"subtitle"]];  
CLLocationCoordinate2D coordinate;   
coordinate.latitude = // need a float like xx.xxxxx  
coordinate.longitude = // need a float like xx.xxxxx;  
location.coordinate = coordinate;  
[annotations addObject:location];  
[mapView addAnnotations:annotations];  

提前致谢。

4

2 回答 2

3

移动评论以回答

float f = (float)intvalue / 10000000.0f;

希望这可以帮助。

于 2012-04-19T06:54:14.653 回答
2

您必须将整数(实际上用作定点数)除以表示为 true 的 10 的适当幂float

float long_float = longitude / 10000000.0f;
于 2012-04-19T06:50:43.663 回答