我正在尝试将RMPolylineAnnotation添加到我的地图集地图中,但由于某种原因它没有出现。我不确定我是否错过了在绘图过程中使用的调用或函数。我用来添加它的代码如下:
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只是一个字典,其中包含了我的RMPolylineAnnotations初始化中使用的众多点数,见下文:
(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"
);
}
这一切似乎加载得很好并且表明我有一个有效的RMPolylineAnnotation如果我在它之后设置断点但地图上没有显示。我注意到lldb中会出现这种情况:
2014-02-28 11:36:56.579 WildSheffield[7700:70b] -[<RMShape: 0xc13aee0> display]: Ignoring bogus layer size (397983.125000, 470151.031250)
我猜这是导致这个问题的原因,但是我不明白为什么这个层的出现太大了,因为我的坐标数组都非常接近。
有人可以提供有关如何解决此问题的任何建议吗?我已经仔细查看了参考文档,但似乎无法弄清楚我做错了什么。 感谢
编辑1:
我注意到当我放大地图时,我现在收到以下错误:
:CGContextPathContainsPoint:无效的上下文0x0。这是一个 严重错误。此应用程序或它使用的库正在使用 无效的上下文,从而导致整体退化 系统稳定性和可靠性。这个通知是礼貌的:拜托 解决这个问题。在即将到来的更新中,它将成为一个致命的错误。
这可能是问题的原因,但我不确定为什么会发生这种情况,因为我的路线肯定属于地图边界等。是否有一个我没有添加的库?
编辑2:
我也注意到虽然我正在设置我的rmMapView委托,但这个函数永远不会被调用:
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
RMPolylineAnnotation是否不算作实际注释(即不应该调用此方法?),for循环肯定是将它添加到RMMapView中的'_visibleAnnotations'数组。
答案 0 :(得分:2)
我有完全相同的错误,它是由我的代码返回一条长度为零的行(RMShape *)引起的(即P1和P2是相同的点)。这似乎导致了层渲染代码中的零问题。我的代码大致如下,通过添加if()部分,不再有错误: - )
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;
答案 1 :(得分:1)
在我看来,您要为集合中的每个点添加折线实例,而不是包含所有这些点的折线。