Hola estoy haciendo una aplicación de turismo en la cual hay varias cabañas, lugares para comer y visitar en este caso cada una tiene un boton que va a un único mapa en el cual hay marcadores para mostrar la ubicación, y necesito que el centro del mapa cargue dependiendo del botón que fue presionado. agrego el codigo del mapController.
import UIKit
import MapKit
class mapController: UIViewController {
@IBOutlet weak var myMapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
mapTajMahal()
}
func mapTajMahal()
{
//Taj Mahal Coordinates: 27.175015, 78.042139
// Coordinates
let tajLat:CLLocationDegrees = -39.849254
let tajLong:CLLocationDegrees = -71.994215
let tajCoordinate = CLLocationCoordinate2D(latitude: tajLat, longitude: tajLong)
let mocho = CLLocationCoordinate2D(latitude: -39.849152, longitude: -71.943082)
let aitue = CLLocationCoordinate2D(latitude: -39.849581, longitude: -71.945078)
let rucapillan = CLLocationCoordinate2D(latitude: -39.833403841808995, longitude:-72.07239013854979)
let c_elportal = CLLocationCoordinate2D(latitude: -39.848834,longitude: -71.937480)
let c_los_alamos = CLLocationCoordinate2D(latitude: -39.851652, longitude: -71.931052)
let c_lago_neltume = CLLocationCoordinate2D(latitude: -39.77999, longitude: -71.95708)
let c_peumayen = CLLocationCoordinate2D(latitude: -39.848467, longitude: -71.938013)
let domos = CLLocationCoordinate2D(latitude: -39.850835, longitude: -71.940623)
let patagonia = CLLocationCoordinate2D(latitude: -39.858635, longitude: -71.918520)
let madero = CLLocationCoordinate2D(latitude: -39.858635, longitude: -71.918520
)
//Span
let latDelta:CLLocationDegrees = 0.2
let longDelta:CLLocationDegrees = 0.2
let tajSpan = MKCoordinateSpan(latitudeDelta: latDelta, longitudeDelta: longDelta)
let tajRegion = MKCoordinateRegion(center: tajCoordinate, span: tajSpan)
myMapView.setRegion(tajRegion, animated: true )
let tajAnnotation = MKPointAnnotation()
tajAnnotation.title = "Neltume"
tajAnnotation.subtitle = "She walks in beauty"
tajAnnotation.coordinate = tajCoordinate
let mochoannotation = MKPointAnnotation()
mochoannotation.title = "Mocho Neltume"
mochoannotation.coordinate = mocho
let aitueanotation = MKPointAnnotation()
aitueanotation.title = "Aitue Expediciones"
aitueanotation.coordinate = aitue
let rucapillananotation = MKPointAnnotation()
rucapillananotation.title = "Rafting Excursiones Restaurant Hostal Cabañas Rucapillan"
rucapillananotation.coordinate = rucapillan
let c_elportalanotation = MKPointAnnotation()
c_elportalanotation.title = "Cabañas el Portal"
c_elportalanotation.coordinate = c_elportal
let c_los_alamosanotation = MKPointAnnotation()
c_los_alamosanotation.title = "Cabañas los Alamos"
c_los_alamosanotation.coordinate = c_los_alamos
let c_lago_neltumeanotation = MKPointAnnotation()
c_lago_neltumeanotation.title = "Cabañas Lago Neltume"
c_lago_neltumeanotation.coordinate = c_lago_neltume
let c_peumayenatonation = MKPointAnnotation()
c_peumayenatonation.title = "Cabañas Peumayen"
c_peumayenatonation.coordinate = c_peumayen
let domosanotation = MKPointAnnotation()
domosanotation.title = "Cabañas Karü Domos del Fuy"
domosanotation.coordinate = domos
let patagoniaanotation = MKPointAnnotation()
patagoniaanotation.title = "Cabañas Patagonia Mawida"
patagoniaanotation.coordinate = patagonia
let maderoanotation = MKPointAnnotation()
maderoanotation.title = "Restaurante Refugio del Madero"
maderoanotation.coordinate = madero
myMapView.addAnnotation(mochoannotation)
myMapView.addAnnotation(aitueanotation)
myMapView.addAnnotation(rucapillananotation)
myMapView.addAnnotation(c_elportalanotation)
myMapView.addAnnotation(c_los_alamosanotation)
myMapView.addAnnotation(c_lago_neltumeanotation)
myMapView.addAnnotation(c_peumayenatonation)
myMapView.addAnnotation(patagoniaanotation)
myMapView.addAnnotation(maderoanotation)
}
}