简体   繁体   English

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

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

I'm using SampleMap example to draw path between 2 points and than move maps from start to end. 我使用SampleMap示例在2点之间绘制路径,然后将地图从头到尾移动。 When map moves, part of path that was out of visible area , becomes invisible until user drag map with finger. 当地图移动时,路径的超出可见区域的部分将变为不可见,直到用户用手指拖动地图。 Anyone have similar problem? 有人有类似的问题吗? any suggestions to fix that? 有什么建议可以解决吗? Here is code I'm using to draw path and move map: 这是我用来绘制路径和移动地图的代码:

//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;

As workaround Im calling moveBy on each moveToLatLong . 作为解决方法,我在每个moveToLatLong上调用moveBy。

[mapView moveToLatLong:slideLocation]; [mapView moveToLatLong:slideLocation];

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

it works but Im not sure if its correct way to avoid this bug. 它可以工作,但是我不确定是否可以避免此错误的正确方法。

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

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