user3745888
user3745888

Reputation: 6353

How to zoom mapView and setCenterCoordinate at the same time?

I have a mapView and I use didUpdateLocations to show location user, but I also use setCenterCoordinate to show the pin blue circle predeterminate for show the location in left of the mapView. But if I use setCenterCoordinate the map not does zoom...

 churchLocation.longitude += self.mapView.region.span.longitudeDelta * 0.15;

    churchLocation.latitude += self.mapView.region.span.latitudeDelta * 0.10;

 self.mapView.setRegion(theRegion, animated: true)
    self.mapView.setCenterCoordinate(churchLocation, animated: true)

How can I do this?

Thanks!

Upvotes: 1

Views: 744

Answers (1)

Craig
Craig

Reputation: 8304

setRegion and setCenterCoordinate are going to work against each other. The view will be looking at the center of theRegion, then you're trying to move it to look at churchLocation.

If you want to set both the zoom level and the you should use the churchLocation and calculate a region around it and then call setRegion with that.

Upvotes: 1

Related Questions