What is the difference between latitude, longitude and their delat values

I am new to MKMapView (iPhone). I want to add some annotations to Copenhagen (Denmark) map. I have latitude and longitude values ​​at different locations in the city. But I don't know how to get longitudeDelta and latitudeDelta from these places. I am using the Google Maps API to calculate the latitude and longitude values ​​(by web services) of each location on a city map. I need help on how to calculate delta values

thanks

+1


a source to share


1 answer


I'm not sure about your question what purpose you are calculating to calculate lat and long deltas, but the only link I saw when it MKMapView is in the MKCoordinateSpan spec is to set the zoom level of the MapView to display.

I found this code online somewhere that will take a MapView with annotations added to the annotation layer and calculate and adjust the display area to make all annotations visible in the MapView. Maybe this will help



CLLocationCoordinate2D topLeftCoord;
topLeftCoord.latitude = -90;
topLeftCoord.longitude = 180;

CLLocationCoordinate2D bottomRightCoord;
bottomRightCoord.latitude = 90;
bottomRightCoord.longitude = -180;

for(MKAnnotation* annotation in self.mapView.annotations)
{
    topLeftCoord.longitude = fmin(topLeftCoord.longitude, annotation.coordinate.longitude);
    topLeftCoord.latitude = fmax(topLeftCoord.latitude, annotation.coordinate.latitude);

    bottomRightCoord.longitude = fmax(bottomRightCoord.longitude, annotation.coordinate.longitude);
    bottomRightCoord.latitude = fmin(bottomRightCoord.latitude, annotation.coordinate.latitude);
}

MKCoordinateRegion region;
region.center.latitude = topLeftCoord.latitude - (topLeftCoord.latitude - bottomRightCoord.latitude) * 0.5;
region.center.longitude = topLeftCoord.longitude + (bottomRightCoord.longitude - topLeftCoord.longitude) * 0.5;
region.span.latitudeDelta = fabs(topLeftCoord.latitude - bottomRightCoord.latitude) * 1.8; // Add a little extra space on the sides
region.span.longitudeDelta = fabs(bottomRightCoord.longitude - topLeftCoord.longitude) * 1.8; // Add a little extra space on the sides

region = [self.mapView regionThatFits:region];
[self.mapView setRegion:region animated:NO];

      

+1


a source







All Articles