Question

I am developing an App in IOS 5 with different maps. I wanted to zoom each map depending the coordinates that I get from the server. Each map will have different zoom, as I said. I wanted all the coordinates to appear on the map.

Any suggestion?

Was it helpful?

Solution

I've got the best solution for this. First, I must get the max and min values (latitude and longitude) from the server. Finally, I do the following:

CLLocationCoordinate2D min = CLLocationCoordinate2DMake([lati_min floatValue], [longi_min floatValue]);

CLLocationCoordinate2D max = CLLocationCoordinate2DMake([lati_max floatValue], [longi_max floatValue]);

CLLocationCoordinate2D center = CLLocationCoordinate2DMake((max.latitude + min.latitude) / 2.0, (max.longitude + min.longitude) / 2.0);
        MKCoordinateSpan span = MKCoordinateSpanMake(max.latitude - min.latitude, max.longitude - min.longitude);
MKCoordinateRegion region = MKCoordinateRegionMake(center, span);

It works perfectly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top