Only using MapKit for one city

290 views Asked by At

I am not really too sure how to word this into google, so I will attempt to ask it here. I am attempting to use the MapKit to display different routes on a map for only one city. Is there a way to limit the amount of the World Map that can be used in the API?

Any suggestions are appreciated.

2

There are 2 answers

0
Alex Muller On BEST ANSWER

if you add this to viewDidLoad:

MKCoordinateRegion region={{0.0,0.0,},{0,0.0}};
region.center.latitude = 30.44;
region.center.longitude = -84.31;
region.span.latitudeDelta=0.03;
region.span.longitudeDelta=0.03;
[mapView setRegion:region animated:YES]; 
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:NO];
[mapView setDelegate:self]; 

it will center around the lat and long, with the magnification specified by the latDelta and longDelta. The lower those values are, the closer you will be zoomed.

0
Josh Hinman On

MKMapView will notify its delegate whenever the map is scrolled (via delegate methods -mapView:regionWillChangeAnimated: and – mapView:regionDidChangeAnimated:). Perhaps you could write some code in those methods to check and see whether the user has scrolled outside of the city, and if so, use setRegion:animated: to move the map back into the correct bounds.