Quote:
Originally Posted by HockeyHippo
So basically I'm trying to make two zoom functions, zoom in and zoom out.
<snip>
Can I not use a variable here?
|
Of course you can use a variable. The problem is that your methods are set up to take POINTERS to CLLocationDistance values as parameters. CLLocationDistance is a simple data type. You don't want the asterisks in the parameter types. Your method declarations should look like this:
Code:
-(IBAction) zoomOut: (MKMapView *) mapView: (CLLocationDistance) latitudinalMeters: (CLLocationDistance) longitudinalMeters
{
//code
}
-(IBAction) zoomIn: (MKMapView *) mapView: (CLLocationDistance) latitudinalMeters: (CLLocationDistance) longitudinalMeters
{
//code
}
Another problem with your code is that you are setting the initial span to 200 kilometers, which is pretty big, and then zooming in or out by 1 km for each click. Initially, that will make for a 0.5% change in zoom level. However, if you click "zoom out" enough times, the zoom level will go negative. Bad things will likely happen if you try to specify a negative zoom level.
If instead you zoom OUT over and over from 200 km, the 1KM you add each time will be a smaller and smaller change in total zoom level to the point where you won't even be able to see the change. Imagine a zoom change from 1000 km to 1001 km. Do you think you could even see it unless you were pixel peeking?
You should really be multiplying/dividing the previous latitudinalMeters/longitudinalMeters values by some constant like 1.1. Multiplying by 1.1 would make the map zoom out 10%, and dividing by 1.1. would make it zoom IN by 10%, no matter what the zoom level. That's what you want.