View Full Version : Setting MKMapViewLocation with Buttons

Apr 21, 2011, 07:15 PM
Pretty new to app development, still in the learning process.

In my app, I have three buttons for three different location. I want to set each button to take you to a different location, how would I achieve this?

I read through the documentation here (http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html#//apple_ref/occ/instm/MKMapView/setCenterCoordinate:animated:), but still don't have an answer. Can someone help out?

Apr 29, 2011, 01:52 PM
Do you have the basics setup? By that I mean, does your app currently show a specified location? There's a bunch of tutorials on using the MapKit.

You need to setup a CLLocationCoordinate2D property and set it to the specific location for each button. Then you can create a region that contains this location and pass that to your mapView.

Look here: http://blog.objectgraph.com/index.php/2009/04/03/iphone-sdk-30-playing-with-map-kit-part-2/

[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];