문제

그래서 Parse 좌표를 검색하고 Mapbox를 사용하여 모양을 그리는 방법을 궁금합니다.

나는 좌표를 검색하고 개별적으로 플롯 할 수 있습니다 ( 구문 분석 )지도 잘 :

PFQuery *locationQuery = [PFQuery queryWithClassName:@"Location"];
[locationQuery whereKeyExists:@"location"];
locationQuery.cachePolicy = kPFCachePolicyNetworkElseCache;
[locationQuery 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]);

        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: %f", location.latitude);

            CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(location.latitude, location.longitude);

            //This is how to populate the data with a title
            NSString *title = [NSString stringWithFormat:@"%@", gp.createdAt];

            RMPointAnnotation *annotation3 = [[RMPointAnnotation alloc] initWithMapView:mapView coordinate:coordinate andTitle:title];
            [mapView addAnnotation:annotation3];

        }

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

맵에 모양 추가 ( Makbox) )

//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
.

ObjectAtIndex : 0]). 좌표 Andtitle : @ "Hola Biatches!"];

    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;


}
.

이 좌표에서 모양을 그릴 수 있도록 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]);
        }
    }];
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top