我需要 circle一个圈子,以显示我所策划的距离。
我在什么地方执行这两条法典,使之发挥作用? 我尝试将其列入<条码>viewWillAppear:,但圈子没有出现。
[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;
}