Quote:
Originally Posted by Alexj17
Hey All
Ive done my best to google this and fix it myself but i just cant.
My problem is drawing multiple overlays only once.
I have a timer which checks my PHP every 3 seconds and gets the co-ords to draw the circle. In my time i have this....
Code:
for(int i = 0; i < [Details count]; i++)
{
NSDictionary *dict2 = [Details objectAtIndex:i];
float Mlat = [[dict2 objectForKey:@"missile_lat"] floatValue];
float Mlong = [[dict2 objectForKey:@"missile_long"] floatValue];
float radius = [[dict2 objectForKey:@"missile_blast_meters"] floatValue];
CLLocationCoordinate2D seoul = {Mlat,Mlong};
MKCircle* circle = [MKCircle circleWithCenterCoordinate:seoul radius:radius];
[myMap addOverlay:circle];
}
Then i have the code to draw a circle.
Code:
-(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id)overlay{
MKCircleView* circleView = [[[MKCircleView alloc] initWithOverlay:overlay] autorelease];
circleView.strokeColor = [UIColor redColor];
circleView.lineWidth = 1.0;
circleView.fillColor = [UIColor colorWithRed:(255 / 255.0) green:(0 / 255.0) blue:(0 / 255.0) alpha: 0.1];
return circleView;
}
Now the problem i am having is that every 3 seconds the circles are drawn, they are not being removed then redrawn and they are not being checked if duplicates.
I need some help please...
Alex
|
It sounds to me like you are adding all the overlays to your map every time you read your PHP data.
Are you saying that you want your overlays to be removed and re-added every 3 seconds, or are you adding new circles but keeping the old ones around?
If you are adding new ones, you need to keep track of the old count and only add the new ones on each pass.
If you want to remove all the circles and completely re-add them every 3 seconds, you might want to re-think. That will be a lot of work for the map to do on a repeating basis. Better to change the coordinate and radius of your existing circle objects, and only add new ones.
In any case, you need to figure out what you want to do, and code logic that manages the list of overlays to do what you want.
If you want to remove all your overlays and re-add them every 3 seconds, use code like this to remove the old ones:
Code:
[myMap removeOverlays: [myMap overlays]];