Question

I am new to ios and working on map view i have showned position on map view (Annotation)using lat, long. map view is showing location, but need to do pinching to get exact location.(zoom with two fingures) I am using following code but it not showing exact location for exact location i need to use zoom then is showing exact location but i want to display it without touching to map view??

zoomLocation.latitude = latmpa.doubleValue;
zoomLocation.longitude = logmpa.doubleValue;
annotationPoint = [[MKPointAnnotation alloc] init];
annotationPoint.coordinate = zoomLocation;
annotationPoint.title = @"masjid....";
[mapView selectAnnotation:annotationPoint animated:YES];

[mapView addAnnotation:annotationPoint];

mapView.centerCoordinate = annotationPoint.coordinate;
Was it helpful?

Solution

You need to work out the region you want the map to be looking at and then use [mapView setRegion:newRegion animated:YES] ref.

An MKCoordinateRegion is made of a CLLocationCoordinate2D which you've already made and a MKCoordinateSpan. Here's an example of making a span

MKCoordinateSpan span;
span.latitudeDelta = 1.5;
span.longitudeDelta = 1.0;
MKCoordinateRegion newRegion;
newRegion.center = zoomLocation;
newRegion.span = span;
[mapView setRegion:newRegion animated:YES];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top