【发布时间】:2014-05-27 00:29:54
【问题描述】:
我尝试通过 Geopoint 将 GeoPoint 转换为 Array 到 String 到 Array。我想使用这个数组在地图套件中绘制折线。 现在我可以转换为字符串但不能包含数组。 我如何将所有字符串包含到数组中 有没有其他方法可以使用 GeoPoint 在地图套件中绘制折线?
- (void)updateLocations {
CGFloat kilometers = self.radius/1000.0f;
PFQuery *query = [PFQuery queryWithClassName:@"Location"];
[query setLimit:1000];
[query whereKey:@"location"
nearGeoPoint:[PFGeoPoint geoPointWithLatitude:self.location.coordinate.latitude
longitude:self.location.coordinate.longitude]
withinKilometers:kilometers];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
static NSNumberFormatter *numberFormatter = nil;
if (numberFormatter == nil) {
numberFormatter = [[NSNumberFormatter alloc] init];
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
numberFormatter.maximumFractionDigits = 6;
}
//NSArray *path = [objects valueForKey:@"location"]; //dictionary to array!!!
//NSLog(@"%@ %@",objects,path);
NSMutableArray *muarray;
for (PFObject *object in objects) {
PFGeoPoint *geoPoint = object[@"location"];
NSString *string = [NSString stringWithFormat:@"{%@, %@}",
[numberFormatter stringFromNumber:[NSNumber numberWithDouble:geoPoint.latitude]],
[numberFormatter stringFromNumber:[NSNumber numberWithDouble:geoPoint.longitude]]];
NSLog(@"%@",string);
[muarray addObject:string]; //I'm try this but it's fail.
NSLog(@"%@",muarray);
}
}
}];
}
【问题讨论】:
-
它是怎么失败的?什么错误?
-
获取日志muarray值“(null)”
-
是的,我回答了这个问题——我在问完这个问题后就注意到了这个问题 :)
标签: ios arrays mapkit polyline geopoints