Search code examples
iosviewuiviewcontrollermkmapviewmkannotationview

Map view not focus on annotation


Hello i am new to ios and showing an annoatation on map view using lat and long coming from server. I have one view controller in which i am adding map and showing position of lat and long. But my problem is whenever i am adding annotation map is not focusing on annotattion insted of it everytime i want pinch map view then map is going to at annoatation i dont know why this is happening?

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];

here is my code adding in viewwillappera  

Solution

  • You need to center the map by use the following code.

    mapView.centerCoordinate = annotationPoint.coordinate;