Elliott D'Alvarez
Elliott D'Alvarez

Reputation: 1237

RMPolylineAnnotation not appearing on map (mapbox)

I'm trying to add an RMPolylineAnnotation to my mapbox map but for some reason it's not appearing. I'm not sure if I'm missing a call or a function that's used in the drawing process. The code I'm using to add it is below:

for (id key in dFeatures)
        {
            RMPolylineAnnotation *polylineAnnotation = [[RMPolylineAnnotation alloc] initWithMapView:self.rmMapView points:[dFeatures objectForKey:key]];
            [polylineAnnotation setLineWidth:10.0f];
            [polylineAnnotation setLineColor:[UIColor orangeColor]];

            [self.rmMapView addAnnotation:polylineAnnotation];
        }

dFeatures is just a dictionary which contains numerous arrays of points used in the initialisation of my RMPolylineAnnotations, see below:

(lldb) po dFeatures
{
    "Blacka_trail_a" =     (
        "<-1.58483448,+53.32148646> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58471249,+53.32137547> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58458351,+53.32126949> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58444752,+53.32116250> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58430553,+53.32103852> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58421054,+53.32094053> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58407455,+53.32084955> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58395256,+53.32076356> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58385757,+53.32067257> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58368158,+53.32054159> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58351160,+53.32040561> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58338261,+53.32028262> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58326062,+53.32017964> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58312563,+53.32006065> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58298264,+53.31996566> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58288065,+53.31986368> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58275166,+53.31976469> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58265767,+53.31965771> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58244669,+53.31949373> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58233870,+53.31939874> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58225070,+53.31930475> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58210072,+53.31921777> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58199972,+53.31908678> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58185674,+53.31899580> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58177574,+53.31893480> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58172075,+53.31897880> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58167276,+53.31901980> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58156977,+53.31901980> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58146679,+53.31904380> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58137080,+53.31906379> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58127481,+53.31910879> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58114483,+53.31915279> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58098685,+53.31920178> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58085687,+53.31924278> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58075388,+53.31927878> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58059590,+53.31935577> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58044492,+53.31938777> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58032894,+53.31942477> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58028094,+53.31944077> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58020495,+53.31947376> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58018396,+53.31948576> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58025895,+53.31952676> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58035494,+53.31954775> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58044993,+53.31954375> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58051892,+53.31953975> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58064190,+53.31951975> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58075789,+53.31952075> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58088088,+53.31954075> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58092187,+53.31959474> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58092788,+53.31965973> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58100187,+53.31975472> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58108386,+53.31982871> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58108987,+53.31989370> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58110287,+53.31994670> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58119786,+53.32000069> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58125185,+53.32003368> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58132685,+53.32010367> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58134685,+53.32015667> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58141484,+53.32023866> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58146084,+53.32034164> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58152184,+53.32041963> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58148684,+53.32053362> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58151284,+53.32060761> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58151285,+53.32067260> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58149085,+53.32078359> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58148386,+53.32085258> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58146186,+53.32092657> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58146187,+53.32100857> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58141288,+53.32111455> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58144588,+53.32118454> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58145188,+53.32125854> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58143788,+53.32131553> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58154087,+53.32132353> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58168385,+53.32131253> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58182084,+53.32132452> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58193682,+53.32132552> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58208081,+53.32132552> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58229278,+53.32133451> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58241577,+53.32135151> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58257975,+53.32135251> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58272973,+53.32135651> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58278472,+53.32134851> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58291471,+53.32134950> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58304369,+53.32137050> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58318768,+53.32137450> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58339265,+53.32137149> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58350164,+53.32140049> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58365262,+53.32140049> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58380260,+53.32141348> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58391859,+53.32142248> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58410357,+53.32142248> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58422656,+53.32143947> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58436954,+53.32144847> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58455452,+53.32146547> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58465651,+53.32147446> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58471850,+53.32147846> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time",
        "<-1.58484048,+53.32148646> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2/28/14, 11:07:56 AM Greenwich Mean Time"
    );
}

This all seems to load in fine and shows that I have a valid RMPolylineAnnotation if I set a breakpoint after it but nothing shows on the map. I have noticed this coming up in the lldb though:

2014-02-28 11:36:56.579 WildSheffield[7700:70b] -[<RMShape: 0xc13aee0> display]: Ignoring bogus layer size (397983.125000, 470151.031250)

I'm guessing this is the cause of the issue but I don't understand why the layer is coming out so large as my array of coordinates are all fairly closely placed.

Can anyone offer any advice on how to fix this issue? I have looked through the reference docs so much but can't seem to work out what I'm doing wrong. Thanks

EDIT 1:

I have noticed that when I zoom in to the map I get the following error now:

: CGContextPathContainsPoint: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

This could be the cause of the issue but I'm not sure why it would be happening as my route definitely falls within the map boundaries etc. Is there a library I haven't added potentially?

EDIT 2:

I have also noticed that although I am setting my rmMapView delegate this function is never called:

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

Does the RMPolylineAnnotation not count as an actual annotation (i.e. should it not call this method?), the for loop is definitely adding it to the '_visibleAnnotations' array in the RMMapView.

Upvotes: 2

Views: 492

Answers (2)

SnowPaddler
SnowPaddler

Reputation: 77

I had exactly the same error and it was caused by my code returning a line (RMShape *) that had zero length (i.e. P1 and P2 were the same point). It seems that this caused some divide by zero issues in the layer rendering code. My code was roughly as follows, and by adding the if() section, no more errors :-)

RMShape *path = [[RMShape alloc] initWithView:mapView];
CLLocation * p1 = _currentWayPoint.coord;
...
CLLocation * p2 = bisectLocation;

float bisectLength = [p1 distanceFromLocation:p2];
if (bisectLength == 0.0f)
{
    NSLog(@"Ignoring invalid bisect length %f", bisectLength);
    return nil;
}

[path moveToCoordinate:p1.coordinate];
[path addLineToCoordinate:p2.coordinate];
return path;

Upvotes: 2

incanus
incanus

Reputation: 5128

It looks to me like you are adding an instance of a polyline for every point in your set, instead of one polyline that includes all of those points.

Upvotes: 1

Related Questions