Reputation: 481
I am trying to add a circular overlay in ios mapview,in view did load i added following code
CLLocationCoordinate2D center = CLLocationCoordinate2DMake( 53.809638, -1.554586 );
MKCircle *circle = [MKCircle circleWithCenterCoordinate:center radius:1000];
circle.title = @"University of Leeds";
[self.map addOverlay:circle];
and also included the delegate function
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay {
if ([overlay isKindOfClass:[MKCircle class]]) {
MKCircleView *circleView = [[MKCircleView alloc] initWithCircle:(MKCircle*)overlay];
circleView.fillColor = [[UIColor redColor] colorWithAlphaComponent:0.2];
circleView.strokeColor = [[UIColor redColor] colorWithAlphaComponent:0.7];
circleView.lineWidth = 2;
return circleView;
}
but it's not working why? thanks
Upvotes: 1
Views: 277
Reputation: 3461
You have to implement the method GetOverlayRenderer which should create a MKCircleRenderer. Below an example in Xamarin.
MKOverlayRenderer GetOverlayRenderer(MKMapView _nativeMapView, IMKOverlay overlay)
{
if (overlay is MKCircle)
{
// Create a renderer if needed
if (_circleRenderer == null)
{
_circleRenderer = new MKCircleRenderer(overlay as MKCircle);
_circleRenderer.FillColor = UIColor.Red;
_circleRenderer.Alpha = 0.3f;
}
return _circleRenderer;
}
Upvotes: 0
Reputation: 391
Is your map
delegate set?
If your creating your map in Interface Builder: Check if you map is properly connected.
(Note that radius is in meters)
Upvotes: 1