Estoy tratando de dibujar una línea recta entre dos puntos en la vista de superposición. En el método MKOverlayView, creo que estoy haciendo correctamente, pero no entiendo por qué no está dibujando ninguna línea ...líneas no se dibujan en la vista de superposición
¿Alguien sabe por qué?
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale
inContext:(CGContextRef)context
{
UIGraphicsPushContext(context);
MKMapRect theMapRect = [[self overlay] boundingMapRect];
CGRect theRect = [self rectForMapRect:theMapRect];
// Clip the context to the bounding rectangle.
CGContextAddRect(context, theRect);
CGContextClip(context);
CGPoint startP = {theMapRect.origin.x, theMapRect.origin.y};
CGPoint endP = {theMapRect.origin.x + theMapRect.size.width,
theMapRect.origin.y + theMapRect.size.height};
CGContextSetLineWidth(context, 3.0);
CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
CGContextBeginPath(context);
CGContextMoveToPoint(context, startP.x, startP.y);
CGContextAddLineToPoint(context, endP.x, endP.y);
CGContextStrokePath(context);
UIGraphicsPopContext();
}
Gracias por su ayuda.
¡Funcionó! ¡¡¡Muchas gracias!!! –
Hola, tengo una pregunta más ... Si debo inicializar CGPoint desde boundingMapRect, ¿cómo debería hacerlo ???? –
oh .. y la razón por la que no estoy usando MkPolylineView es que necesito dibujar una flecha no solo en línea recta ... –