2012-10-04 21 views
5

Ho utilizzato il seguente codice per ingrandire la vista mappa, in modo che tutte le annotazioni vengano visualizzate contemporaneamente nella visualizzazione con il livello di zoom ottimale. Ma in IOS 6, sembra esserci qualche problema con il livello di zoom. Provando alcuni casi, ho trovato che 1. Se i contatti sono negli Stati Uniti, quando viene caricata la mappa è lo zoom altrove. 2. Il livello di zoom sembra essere corretto nell'area del Regno Unito (per quanto ho testato). 3. Quando includo i contatti sia dal Regno Unito che dagli Stati Uniti, i contatti del Regno Unito vengono correttamente ingranditi, ma i contatti degli Stati Uniti sono fuori dal campo visivo. Tuttavia, un leggero sfioramento farà sì che tutti i contatti entrino nella vista e siano zumati correttamente.Comportamento indifferente del livello di zoom in 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]; 
} 

Dopo aver caricato il mapview con annotazioni, in casi casuali ricevo il seguente 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.)\"" 
)} 

Quale potrebbe essere la ragione di questo e come posso correggerlo? Non ho trovato nulla di utile dopo aver fatto ricerche su Google.

Non sono in grado di identificare alcun modello particolare per questa incoerenza dello zoom. Il codice sopra riportato funziona perfettamente nelle precedenti versioni di IOS.

risposta

2

Ho quasi offerto una taglia sulla tua domanda, ma poi ho notato che con le nuove mappe in iOS6 non è possibile eseguire lo zoom indietro per vedere il mondo intero (provalo nell'app delle mappe). C'è un livello massimo di zoom che si può capire commentando il ciclo for e la registrazione in questo modo:

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

L'output è simile al seguente:

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

Come posso risolvere questo problema.? –

+0

Questa è una domanda concettuale. Ad esempio, puoi provare a mostrare un massimo di posizioni che sono più importanti per l'utente. In realtà dipende dal tuo caso d'uso. Potresti anche voler ricorrere alle mappe statiche google o aggiungere un altro servizio di mappe alla tua app. Tocca a voi. – borisdiakur

+0

Non c'è comunque che io possa farlo con le mappe di google –

Problemi correlati