我尝试通过 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);
}
}
}];
}