Note that there are some explanatory texts on larger screens.

plurals
  1. POMKPolyline not showing on MKMapView
    primarykey
    data
    text
    <p>Here's the code. Its pretty straight forward. I'm making a path for someone who is walking. So, here's the code for my <code>ViewController.m</code> file : </p> <pre><code>#import "ViewController.h" @interface ViewController () @property BOOL firstTime; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self.mapView setDelegate:self]; [self.mapView setShowsUserLocation:YES]; [self.mapView setMapType:MKMapTypeHybrid]; [self setLocationManager:[[CLLocationManager alloc] init]]; [self.locationManager setDelegate:self]; [self.locationManager setDistanceFilter:kCLDistanceFilterNone]; [self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [self.locationManager startUpdatingLocation]; self.index = 0; self.firstTime = YES; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { if(self.firstTime) { CLLocation *startingLocation = [locations objectAtIndex:0]; self.startingPointCooridinates = startingLocation.coordinate; self.index++; MKPointAnnotation *startingPointAnnotation = [[MKPointAnnotation alloc] init]; startingPointAnnotation.title = @"Starting Point"; startingPointAnnotation.coordinate = startingLocation.coordinate; [self.mapView addAnnotation:startingPointAnnotation]; self.firstTime = false; } [self.locations addObject:[locations objectAtIndex:0]]; CLLocationCoordinate2D coordinates[[self.locations count]]; for(int i = 0; i &lt; self.locations.count; i++) { CLLocation *currentLocation = [locations objectAtIndex:i]; coordinates[i] = currentLocation.coordinate; } MKPolyline *pathPolyline = [MKPolyline polylineWithCoordinates:coordinates count:self.locations.count]; [self.mapView addOverlay:pathPolyline]; } - (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id&lt;MKOverlay&gt;)overlay { if([overlay isKindOfClass:[MKPolyline class]]) { MKPolylineRenderer *polylineRenderer = [[MKPolylineRenderer alloc] initWithPolyline:overlay]; polylineRenderer.fillColor = [[UIColor redColor] colorWithAlphaComponent:0.2]; polylineRenderer.strokeColor = [[UIColor redColor] colorWithAlphaComponent:0.7]; polylineRenderer.lineWidth = 2.0; return polylineRenderer; } else { return nil; } } </code></pre> <p>Now, only the annotation is showing and there isn't any <code>MKPolyline</code> showing up. What am I doing wrong ? Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload