views:

186

answers:

0

I need to get some kind of scaling factor which tells me by how much the map has zoomed (whenever the region changes).

My first idea was to use the span's delta latitude or longitude values. I would keep a track of the 'old' value and then update the value when the map region changes and compare the ratio with the old value.

I'm using the following delegate method:

- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
    // Get the new value
    CLLocationDegrees newdlat = mapView.region.span.latitudeDelta;

    // Find the zoom ratio (use longitude instead?)
    CGFloat zoomRatio = newdlat / olddlat;

    // Update the old value (defined elsewhere)
    olddlat = newdlat;
}

I'm not using the longitude delta in this case because I figure it would scale proportionally to the latitude which would yield the same ratio (is this wrong?).

The problem is when I check the values of the longitude and latitude deltas while scrolling the map (without zooming) the values keep changing slightly. Shouldn't the span values stay the same if the map isn't zooming? Maybe I misunderstood something.

Due to this little variation I'm worried that my zoom ratio won't be accurate enough to rely on (ultimately I'm going to use it to scale annotation images with the map).

My main question is is this an good approach or is there a much simpler way that I'm overlooking?

Thanks for any help.