I am new to IOS programming.
I know how to draw MKCirlcle on map with given coordinates and radius. But, I want to draw a circle like shape but not exactly circle. I want to draw an ellipse like shape on map around MKRoute. This shape will be starting at location one mile before user location and end at location one mile after destination. Height of ellipse will be two miles. One mile above the route and one mile below. This shape should proceed with route direction.
Here is the required shape.
https://i.stack.imgur.com/18QyV.png
In my home controller , I am doing this.
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id < MKOverlay >)overlay
{
double ppm = MKMapPointsPerMeterAtLatitude(RouteDisplayed.polyline.coordinate.latitude);
CustomOverlayRenderer *renderer = [[CustomOverlayRenderer
alloc] initWithOverlay:overlay];
renderer.ppm =[NSNumber numberWithDouble:ppm];
renderer.strokeColor = [UIColor colorWithRed:0.0 green:1.0 blue:0.0 alpha:.3];
return renderer;
}
And below is my CustomOverlayRenderer.h extending from MKPolylineRenderer.
#import <MapKit/MapKit.h>
@interface CustomOverlayRenderer : MKPolylineRenderer
- (void)drawMapRect:(MKMapRect)mapRect
zoomScale:(MKZoomScale)zoomScale
inContext:(CGContextRef)context;
@property(nonatomic, strong) NSNumber * ppm;
@end
And below in CustomOverleyRenderer.m
@implementation CustomOverlayRenderer
- (void)drawMapRect:(MKMapRect)mapRect
zoomScale:(MKZoomScale)zoomScale
inContext:(CGContextRef)context
{
[super drawMapRect:mapRect zoomScale:zoomScale inContext:context];
double p = [self.ppm doubleValue];
CGContextSetLineWidth(context, (p * 3200)/zoomScale);
}
@end
Hope, I explained my question well.
If there is any ambiguity, you can ask me.
Thanks in advance.