iOS解析地理点&;地图盒形状

iOS解析地理点&;地图盒形状,ios,parse-platform,mapbox,Ios,Parse Platform,Mapbox,所以我想知道如何使用MapBox检索解析坐标和绘制形状 我可以检索坐标并在地图上单独(使用)绘制它们: 将形状添加到贴图(使用)也是可行的: 对象索引:0])。坐标和标题:@“Hola biatches!”] 我想知道如何让MapBox从这些坐标中绘制形状?我已经尝试过几次,但都一事无成,所以如果有人比我聪明,我将不胜感激。如果你需要更多的信息,请告诉我 我找到了答案-我尝试的解决方案很好-我在循环中初始化数组,因此它每次都重新创建数组,因此覆盖每个新坐标并尝试仅使用一个坐标绘制形状 PFQue

所以我想知道如何使用MapBox检索解析坐标和绘制形状

我可以检索坐标并在地图上单独(使用)绘制它们:

将形状添加到贴图(使用)也是可行的:

对象索引:0])。坐标和标题:@“Hola biatches!”]


我想知道如何让MapBox从这些坐标中绘制形状?我已经尝试过几次,但都一事无成,所以如果有人比我聪明,我将不胜感激。如果你需要更多的信息,请告诉我

我找到了答案-我尝试的解决方案很好-我在循环中初始化数组,因此它每次都重新创建数组,因此覆盖每个新坐标并尝试仅使用一个坐标绘制形状

PFQuery *locationQuery2 = [PFQuery queryWithClassName:@"Location"];
    [locationQuery2 whereKeyExists:@"location"];
    locationQuery2.limit = 4;
    locationQuery2.cachePolicy = kPFCachePolicyNetworkElseCache;
    [locationQuery2 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
            // The find succeeded.
            NSLog(@"Successfully retrieved %lu scores.", (unsigned long)objects.count);
            NSLog(@"Object is %@ and %@", [objects objectAtIndex:0],[objects objectAtIndex:1]);
            NSMutableArray *locations = [[[NSMutableArray alloc] init] mutableCopy];

            for (PFObject *gp in objects) {

                //How to get PFGeoPoint and then a location out of an object
                PFGeoPoint *location = [gp objectForKey:@"location"];

                NSLog(@"Hi there my name is not: %f", location.latitude);

                CLLocation *coordinate = [[CLLocation alloc] initWithLatitude:location.latitude longitude:location.longitude];

                //Line for streets location arrays, etc MapBox
                [locations addObject:coordinate];

                RMAnnotation *annoation43 = [[RMAnnotation alloc] initWithMapView:mapView coordinate:((CLLocation *)[locations objectAtIndex:0]).coordinate andTitle:@"Hola biatches!"];

                annoation43.userInfo = locations;
                [annoation43 setBoundingBoxFromLocations:locations];
                [mapView addAnnotation:annoation43];
                NSLog(@"It is working Dora!");


                NSLog(@"Yeah its is: %@", locations);
            }

        } else {
            // Log details of the failure
            NSLog(@"Error: %@ %@", error, [error userInfo]);
        }
    }];

因此,我倾向于将其作为地质点和位置转换的问题。
//Line for streets location arrays, etc MapBox
    NSArray *locations = [NSArray arrayWithObjects:[[CLLocation alloc] initWithLatitude:-33.980852 longitude:151.072498],
                          [[CLLocation alloc] initWithLatitude:-33.981769 longitude:151.072300],
                          [[CLLocation alloc] initWithLatitude:-33.982018 longitude:151.072257],
                          [[CLLocation alloc] initWithLatitude:-33.982187 longitude:151.072225], nil, nil];

    RMAnnotation *annoation43 = [[RMAnnotation alloc] initWithMapView:mapView coordinate:((CLLocation *)[locations
    annoation43.userInfo = locations;
    [annoation43 setBoundingBoxFromLocations:locations];
    [mapView addAnnotation:annoation43];
    NSLog(@"It is working Dora!");

-(RMMapLayer *)mapView:(RMMapView *)mapViewer layerForAnnotation:(RMAnnotation *)annotation {

    if (annotation.isUserLocationAnnotation)
        return nil;

    RMShape *shape = [[RMShape alloc] initWithView:mapView];

    //Line dashes and colours and widths, etc
    shape.lineColor = [UIColor orangeColor];
    shape.lineWidth = 4.0;
    shape.scaleLineWidth = YES;
    shape.scaleLineDash = YES;
    shape.lineDashLengths = [NSArray arrayWithObjects:[NSNumber numberWithInt:4], [NSNumber numberWithInt:6], nil];
    shape.lineDashPhase = 3.0f;



    for (CLLocation *location in (NSArray *)annotation.userInfo)
        [shape addLineToCoordinate:location.coordinate];

    return shape;


}
PFQuery *locationQuery2 = [PFQuery queryWithClassName:@"Location"];
    [locationQuery2 whereKeyExists:@"location"];
    locationQuery2.limit = 4;
    locationQuery2.cachePolicy = kPFCachePolicyNetworkElseCache;
    [locationQuery2 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
            // The find succeeded.
            NSLog(@"Successfully retrieved %lu scores.", (unsigned long)objects.count);
            NSLog(@"Object is %@ and %@", [objects objectAtIndex:0],[objects objectAtIndex:1]);
            NSMutableArray *locations = [[[NSMutableArray alloc] init] mutableCopy];

            for (PFObject *gp in objects) {

                //How to get PFGeoPoint and then a location out of an object
                PFGeoPoint *location = [gp objectForKey:@"location"];

                NSLog(@"Hi there my name is not: %f", location.latitude);

                CLLocation *coordinate = [[CLLocation alloc] initWithLatitude:location.latitude longitude:location.longitude];

                //Line for streets location arrays, etc MapBox
                [locations addObject:coordinate];

                RMAnnotation *annoation43 = [[RMAnnotation alloc] initWithMapView:mapView coordinate:((CLLocation *)[locations objectAtIndex:0]).coordinate andTitle:@"Hola biatches!"];

                annoation43.userInfo = locations;
                [annoation43 setBoundingBoxFromLocations:locations];
                [mapView addAnnotation:annoation43];
                NSLog(@"It is working Dora!");


                NSLog(@"Yeah its is: %@", locations);
            }

        } else {
            // Log details of the failure
            NSLog(@"Error: %@ %@", error, [error userInfo]);
        }
    }];