I created annotation for shape
_path = [RMAnnotation annotationWithMapView:_mapView
coordinate: _userLocation.coordinate
andTitle:@"Path"];
[_mapView addAnnotation:_path];
in delegate I wrote
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
if ([annotation.title isEqualToString:@"Path"])
{
_lineBetweenTwoBeacon = [[RMShape alloc] initWithView:mapView];
_lineBetweenTwoBeacon.lineColor = [UIColor redColor];
_lineBetweenTwoBeacon.lineWidth = 10.0f;
return _lineBetweenTwoBeacon;
}
else
{
marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"userPin"]];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)];
imageView.contentMode = UIViewContentModeScaleAspectFit;
marker.leftCalloutAccessoryView = imageView;
return marker;
}
}
Next step I draw shape
[_lineBetweenTwoBeacon addQuadCurveToCoordinate:firstBeaconCoord controlCoordinate:secondBeaconCoord];
But how to remove all shapes from the map and add new shape. Now the shape lay to the shape, it's not correct. Will be better if _lineBetweenTwoBeacon redraw every time.
Thank you, for help!
When you manually create an
RMShape
, you need to tell it where to move and to draw after creating it with methods like-moveToCoordinate:
and-addLineToCoordinate:
. If you just have basic needs, I would recommend tryingRMPolylineAnnotation
, which handles the drawing for you.