繁体   English   中英

Route-Me框架:如果以编程方式移动地图,则RMPath将变得不可见

[英]Route-Me framework: RMPath becomes invisible if moving map programly

我使用SampleMap示例在2点之间绘制路径,然后将地图从头到尾移动。 当地图移动时,路径的超出可见区域的部分将变为不可见,直到用户用手指拖动地图。 有人有类似的问题吗? 有什么建议可以解决吗? 这是我用来绘制路径和移动地图的代码:

//Set map view center coordinate
CLLocationCoordinate2D center;
center.latitude = 47.582;
center.longitude = -122.333;
slideLocation = center;
[mapView.contents moveToLatLong:center];
[mapView.contents setZoom:17.0f];

// Add 2 markers(start/end)  and RMPath with 2 points
RMMarker *newMarker;
UIImage *startImage = [UIImage imageNamed:@"marker-blue.png"];
UIImage *finishImage = [UIImage imageNamed:@"marker-red.png"];
UIColor* routeColor = [[UIColor alloc] initWithRed:(27.0 /255) green:(88.0 /255) blue:(156.0 /255) alpha:0.75];
RMPath* routePath = [[RMPath alloc] initWithContents:mapView.contents];
[routePath setLineColor:routeColor];
[routePath setFillColor:routeColor];
[routePath setLineWidth:10.0f];
[routePath setDrawingMode:kCGPathStroke];
CLLocationCoordinate2D newLocation;
newLocation.latitude = 47.580;
newLocation.longitude = -122.333;   
[routePath addLineToLatLong:newLocation];
newLocation.latitude = 47.599;
newLocation.longitude = -122.333;   
[routePath addLineToLatLong:newLocation];
[[mapView.contents overlay] addSublayer:routePath];

newLocation.latitude = 47.580;
newLocation.longitude = -122.333;   
newMarker = [[RMMarker alloc] initWithUIImage:startImage anchorPoint:CGPointMake(0.5, 1.0)];
[mapView.contents.markerManager addMarker:newMarker AtLatLong:newLocation];
[newMarker release];
newMarker = nil;

newLocation.latitude = 47.599;
newLocation.longitude = -122.333;   
newMarker = [[RMMarker alloc] initWithUIImage:finishImage anchorPoint:CGPointMake(0.5, 1.0)];
[mapView.contents.markerManager addMarker:newMarker AtLatLong:newLocation];
[newMarker release];
newMarker = nil;

作为解决方法,我在每个moveToLatLong上调用moveBy。

[mapView moveToLatLong:slideLocation];

[mapView moveBy:CGSizeMake(0,0)];

它可以工作,但是我不确定是否可以避免此错误的正确方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM