MKCircle não está atualizando o raio, mas está traduzindo
Eu tenho que desenhar um MKCicle em um MKMapView. Então eu tenho que desenhá-lo novamente quando o usuário, através de um controle deslizante, altera o raio. Eu o removo e o recrio, adicionando-o novamente ao mapa. Mas, em vez de fazer o que estou esperando, vejo o MKCircle traduzindo sobre o mapa, mantendo o mesmo tamanh
Aqui está o meu código:
- (MKOverlayView *)mapView:(MKMapView *)map viewForOverlay:(id)overlay
{
MKOverlayView* overlayView = nil;
if(overlay == self.circle)
{
//if we have not yet created an overlay view for this overlay, create it now.
if(nil == self.circleView)
{
self.circleView = [[[MKCircleView alloc] initWithCircle:self.circle] autorelease];
self.circleView.fillColor = [UIColor blueColor];
self.circleView.strokeColor = [UIColor blueColor];
self.circleView.alpha = 50;
self.circleView.lineWidth = 2;
}
overlayView = self.circleView;
}
return overlayView;
}
-(void)drawPolygonWithLocation
{
[self.mapView removeOverlay: self.circle];
MKCoordinateRegion region;
region.center.latitude = self.geofenceLocation.latitude;
region.center.longitude = self.geofenceLocation.longitude;
region.span.latitudeDelta = 0.005;
region.span.longitudeDelta = 0.005;
MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits: region];
[self.mapView setRegion:adjustedRegion animated:TRUE];
self.radius = (double)(slRadius.value);
NSLog(@"Raggio: %f", self.radius);
NSLog(@"Lat: %f, Lon: %f", region.center.latitude, region.center.longitude);
self.circle = [MKCircle circleWithCenterCoordinate:self.geofenceLocation.coordinate radius: self.radius];
NSLog(@"CIRCLE: radius %f Lat: %f, Lon: %f", self.circle.radius, self.circle.coordinate.latitude, self.circle.coordinate.longitude);
[self.mapView addOverlay:self.circle];
}
-(IBAction)updateRadius:(id)sender
{
[self drawPolygonWithLocation];
}
O NSLog está gravando os valores corretos do console, o centro não muda e o raio muda de acordo com a entrada do usuário. Mas, novamente, o MKCircle traduz indo para o noroeste.
Agradecemos antecipadamente, Samuel Rabini