Ich muss einen Kreis zeichnen, um die Entfernung um einen von mir gezeichneten Punkt anzuzeigen.
Wo sollte ich diese beiden Codezeilen implementieren, damit es funktioniert? Ich habe versucht, sie in viewWillAppear:
aber der Kreis wird nicht angezeigt.
[self addCircle:_coordinate];
[self addCircleWithRadius:5.5 addCircleWithCoordinate:_coordinate];
- (void)addCircle: (CLLocationCoordinate2D)coordinate
{
// draw the radius circle for the marker
double radius = 2000.0;
MKCircle *circle = [MKCircle circleWithCenterCoordinate:coordinate radius:radius];
[circle setTitle:@"background"];
[_mapView addOverlay:circle];
MKCircle *circleLine = [MKCircle circleWithCenterCoordinate:coordinate radius:radius];
[circleLine setTitle:@"line"];
[_mapView addOverlay:circleLine];
}
- (void)addCircleWithRadius:(double)radius addCircleWithCoordinate: (CLLocationCoordinate2D) coordinate
{
MKCircle *circle = [MKCircle circleWithCenterCoordinate:coordinate radius:radius];
[circle setTitle:@"background"];
[_mapView addOverlay:circle];
MKCircle *circleLine = [MKCircle circleWithCenterCoordinate:coordinate radius:radius];
[circleLine setTitle:@"line"];
[_mapView addOverlay:circleLine];
}
- (void)sliderChanged:(UISlider*)sender
{
[_mapView removeOverlays:[_mapView overlays]];
double radius = (sender.value * 100);
CLLocationCoordinate2D coordinate = self.coordinate;
[self addCircleWithRadius:radius addCircleWithCoordinate:coordinate];
}
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay{
MKCircle *circle = overlay;
MKCircleView *circleView = [[[MKCircleView alloc] initWithCircle:overlay] autorelease];
if ([circle.title isEqualToString:@"background"])
{
//circleView.fillColor = UIColorFromRGB(0x598DD3);
circleView.alpha = 0.25;
}
else
{
//circleView.strokeColor = UIColorFromRGB(0x5C8AC7);
circleView.lineWidth = 2.0;
}
return circleView;
}