So i am wondering how to go about retrieving Parse coordinates and drawing a shape using MapBox.
I can retrieve the coordinates and plot them individually (using PARSE) on a map fine:
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]); } }];
Adding a shape to a map (using MapBox) is doable as well:
//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]).coordinate 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; }
I am wondering how i would get MapBox to draw a shape from these coordinates? I have had a few attempts and am getting nowhere so someone with a better mind than i would be greatly appreciated. If you need any more information let me know.