Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
[ad_1]
I am making a operate that when it is known as, it would zoom in into the customized pin annotation coordinates and present its title and subtitle. The zoom half works tremendous, the one factor I am unable to do it is the title and subtitle half.
personal func addCustomPinRectoría1() {
let pin1 = MKPointAnnotation()
pin1.coordinate = coordinatesRectoría1
pin1.title = "Rectoría"
pin1.subtitle = "Parada TigreBus"
map.addAnnotation(pin1)
func selectAnnotation(_ vc: ContentViewController, didSelectLocationWith coordinates: CLLocationCoordinate2D?) {
guard let coordinates = coordinates else {
return
}
map.removeAnnotations(map.annotations)
let selectedPin = MKPointAnnotation()
selectedPin.coordinate = coordinates
map.addAnnotation(selectedPin)
// Right here is the place I have to show the pin's title and subtitle robotically
map.setRegion(MKCoordinateRegion(
middle: coordinates,
span: MKCoordinateSpan(latitudeDelta: 0.008, longitudeDelta: 0.008)),
animated: true)
}
I do not know if that is helpful, however I am going to additionally go away this a part of the code:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard !(annotation is MKUserLocation) else {
return nil
}
var annotationView = map.dequeueReusableAnnotationView(withIdentifier: "customized")
if annotationView == nil {
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "customized")
annotationView?.canShowCallout = true
}
else {
annotationView?.annotation = annotation
}
annotationView?.picture = UIImage(named: "TigreBusParada")
annotationView?.body.measurement = CGSize(width: 35, top: 100)
return annotationView
}
[ad_2]