0

I have a pinView in my mapView in Swift but when my mapView load this is showed in the center of mapView. I want know how can display this map moved to show the location and pin in other position, not center.
I'm trying do this with centerOffset annd calloutOffset property, but I don't get that I want

 func mapView (mapView: MKMapView!,
    viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {

        var pinView:MKPinAnnotationView = MKPinAnnotationView()
        pinView.annotation = annotation
        pinView.calloutOffset = CGPointMake(50, 0);
        pinView.pinColor = MKPinAnnotationColor.Green
        pinView.animatesDrop = true
        pinView.canShowCallout = true

        return pinView
}

How can I do this?

Edit: I add this image for show that I want do and ask if is this possible..

enter image description here

Showing in center:

enter image description here

Showing pin in other position:

enter image description here

Thanks!

user3745888
  • 6,143
  • 15
  • 48
  • 97
  • What does this have to do with android-mapview? – matt Sep 04 '14 at 16:30
  • Sorry, the autocompete for tags write android... This is ios, Swift – user3745888 Sep 04 '14 at 16:31
  • Are you asking how to center the whole map view on a certain coordinate? –  Sep 04 '14 at 16:59
  • I want show the map view like second image, when I open my view that contain map vie. So, I want center whole map showing my pin location user in a certain coordinate x,y in the view. I hope I have expressed well. thanks! – user3745888 Sep 04 '14 at 17:05
  • Add your annotation at the coordinate you like and then set the map's `region` property. See http://stackoverflow.com/questions/24467408/swift-add-mkannotationview-to-mkmapview, http://stackoverflow.com/questions/25202613/mapkit-in-swift-part-2 –  Sep 04 '14 at 17:14
  • I think that I 'm expresing bad.. I have added an image shownig that I want do. thanks! – user3745888 Sep 04 '14 at 17:53
  • If the suggestion that @Anna gave doesn't help you, then it's not clear what you are after. Voting to close on that basis. – matt Sep 04 '14 at 18:02
  • I'm not understanding because it is so difficult to understand that I want that my location with his pin does not appear in the center of view when I open the view.. thanks! – user3745888 Sep 04 '14 at 18:16
  • 1
    @user3745888, I think what you want is [this](http://stackoverflow.com/questions/15421106/centering-mkmapview-on-spot-n-pixels-below-pin). Convert the top part of that answer to Swift and instead of updating latitude, update the longitude (and do += instead of -=). –  Sep 04 '14 at 19:08
  • Exactly! I want this. This is the solution, write this like answer and I can vote. Thanks!! – user3745888 Sep 04 '14 at 22:23

0 Answers0