2012-10-04 24 views
5

He estado usando el siguiente código para ampliar la vista de mapa, de modo que todas las anotaciones se mostrarán en la vista al mismo tiempo al nivel de zoom óptimo. Pero en iOS 6, parece haber algún problema con el nivel de zoom. Probando algunos casos, encontré que 1. Si los contactos están en EE. UU., Cuando se carga el mapa, se hace zoom en otro lugar. 2. El nivel de zoom parece ser correcto en el área del Reino Unido (por lo que he probado). 3. Cuando incluyo contactos tanto del Reino Unido como de los EE. UU., Los contactos del Reino Unido se acercan correctamente, pero los contactos de EE. UU. Están fuera de la vista. Pero un ligero deslizamiento asegurará que todos los contactos quepan en la vista y que se amplíen correctamente.Comportamiento indiferente del nivel de zoom en IOS 6 mapview

-(void)zoomToFitMapAnnotations:(MKMapView*)mapViews insideArray:(NSArray*)anAnnotationArray 
{ 
if([mapViews.annotations count] == 0) return; 

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

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

for(MKPointAnnotation* annotation in anAnnotationArray) 
{ 
    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.1; // Add a little extra space on the sides 
region.span.longitudeDelta = fabs(bottomRightCoord.longitude - topLeftCoord.longitude) * 1.1; // Add a little extra space on the sides 

region = [mapViews regionThatFits:region]; 
[mapView setRegion:region animated:YES]; 
} 

Después de cargar el MapView con anotaciones, en los casos azar me sale el siguiente registro

<GEOTileSource: 0x108f6470>: Error downloading tiles Server Error: Error Domain=GEOErrorDomain Code=-204 "The operation couldn’t be completed. (GEOErrorDomain error -204.)" UserInfo=0x18a5b9c0 {UnderlyingErrors=(
"Error Domain=GEOErrorDomain Code=-204 \"The operation couldn\U2019t be completed. (GEOErrorDomain error -204.)\"" 
)} 

Cuál podría ser la razón de esto y cómo puedo corregirlo? No pude encontrar nada útil después de googlear.

No puedo identificar ningún patrón en particular para esta incoherencia de acercamiento. El código anterior funciona bien en versiones anteriores de iOS.

Respuesta

2

Casi ofrecí una recompensa por su pregunta, pero luego me di cuenta de que con los nuevos mapas en iOS6 simplemente no puede alejarse para ver el mundo entero (pruébelo usted mismo en la aplicación de mapas). Hay un nivel de zoom máximo que se puede averiguar comentando su bucle for y el registro de esto:

NSLog(@"region.span.latitudeDelta = %f", region.span.latitudeDelta); 
NSLog(@"longitudeDelta = %f", region.span.longitudeDelta); 

[map setRegion:region animated:NO]; 

NSLog(@"region.span.latitudeDelta = %f", map.region.span.latitudeDelta); 
NSLog(@"longitudeDelta = %f", map.region.span.longitudeDelta); 

La salida tiene el siguiente aspecto:

region.span.latitudeDelta = 179.283409 
longitudeDelta = 360.000000 
region.span.latitudeDelta = 76.269114 
longitudeDelta = 98.437499 
+0

¿Cómo se puede resolver este problema.? –

+0

Esta es una pregunta conceptual. Por ejemplo, puede intentar mostrar un máximo de ubicaciones que son más importantes para el usuario. De hecho, depende de tu caso de uso. También es posible que desee recurrir a los mapas estáticos de Google o agregar otro servicio de mapas a su aplicación. Tu decides. – borisdiakur

+0

No hay, de todos modos, que pueda hacerlo con los mapas de Google –

Cuestiones relacionadas