Question

I am new to using RMPolylines and RMShapes and i think i am executing this code correctly but nothing is showing up on the map:

RMMapBoxSource *tilesource = [[RMMapBoxSource alloc] initWithMapID:kMapID];

[mapView setTileSource:tilesource];

 NSArray *locations = [NSArray arrayWithObjects:[[CLLocation alloc] initWithLatitude:-33.981595 longitude:151.072900],[[CLLocation alloc] initWithLatitude:-33.981560 longitude:151.073544],[[CLLocation alloc] initWithLatitude:-33.981560 longitude:151.073845],[[CLLocation alloc] initWithLatitude:-33.981666 longitude:151.074016], 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];

-(RMMapLayer *)mapView:(RMMapView *)mapViewer layerForAnnotation:(RMAnnotation *)annotation 
{
    if (annotation.isUserLocationAnnotation)
        return nil;

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

    shape.lineColor = [UIColor orangeColor];
    shape.lineWidth = 5.0;

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

    return shape;
    NSLog(@"It is working Dora!");
}

So i think i have done something wrong here but i cannot pick it - if any more code or information is needed just let me know.

Was it helpful?

Solution 2

Okay it is fixed now and seems to be a simple issue but if you know a detailed WHY this happened I would love to hear it!

Added the following:

mapView.delegate = self;

I thought i had already set the delegate but evidently not!

OTHER TIPS

First off, your NSLog() isn't ever going to run because of the return, but that's minor.

I see you basically followed the shape example. I'm not sure what could be wrong. Dumb question, but is the shape onscreen? i.e. is your map view showing an area that's covered by this shape?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top