2012-10-04 16 views
5

में ज़ूम स्तर का उदासीन व्यवहार मैं नक्शादृश्य ज़ूम करने के लिए निम्न कोड का उपयोग कर रहा हूं, ताकि सभी एनोटेशन दृश्यमान ज़ूम स्तर पर एक ही समय में दृश्य में प्रदर्शित किए जाएंगे। लेकिन आईओएस 6 में, ज़ूम स्तर के साथ कुछ समस्या प्रतीत होती है। कुछ मामलों का परीक्षण करते हुए, मैंने पाया कि 1. यदि संपर्क अमेरिका में हैं, जब नक्शा लोड होता है तो यह कहीं और ज़ूम कर रहा है। 2. ज़ूम स्तर यूके क्षेत्र में सही लगता है (जहां तक ​​मैंने परीक्षण किया है)। 3. जब मैं ब्रिटेन और अमेरिका दोनों से संपर्क शामिल करता हूं, तो ब्रिटेन के संपर्कों को सही ढंग से ज़ूम किया जाता है, लेकिन अमेरिकी संपर्क दृश्य से बाहर हैं। लेकिन थोड़ा सा स्वाइप यह सुनिश्चित करेगा कि सभी संपर्क दृश्य में फिट हों और ठीक से ज़ूम किए जाएंगे।आईओएस 6 ज़ूमव्यू

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

एनोटेशन के साथ MapView लोड करने के बाद, यादृच्छिक मामलों में मैं निम्नलिखित लॉग

<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.)\"" 
)} 

मिल क्या यह और मैं इसे कैसे सही कर सकते हैं के लिए कारण हो सकता है? Googling के बाद कुछ भी उपयोगी नहीं मिल सका।

मैं इस ज़ूमिंग असंगतता के लिए किसी भी विशेष पैटर्न की पहचान करने में सक्षम नहीं हूं। उपरोक्त कोड पिछले आईओएस संस्करणों में ठीक काम कर रहा है।

उत्तर

2

मैंने लगभग आपके प्रश्न पर एक बक्षीस की पेशकश की लेकिन फिर मैंने देखा कि आईओएस 6 में नए मानचित्रों के साथ आप पूरी दुनिया को देखने के लिए ज़ूम आउट नहीं कर सकते हैं (इसे मानचित्र ऐप में स्वयं आज़माएं)।

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

उत्पादन इस तरह दिखता है:

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

मैं कैसे इस समस्या को हल कर सकते हैं वहाँ एक अधिकतम ज़ूम स्तर जो आप अपने for पाश बाहर टिप्पणी और प्रवेश करने के लिए इस से यह पता लगाने कर सकते हैं।? –

+0

यह एक वैचारिक सवाल है। उदाहरण के लिए आप अधिकतम स्थानों को दिखाने का प्रयास कर सकते हैं जो उपयोगकर्ता के लिए सबसे महत्वपूर्ण हैं। यह वास्तव में आपके उपयोग के मामले पर निर्भर करता है। आप Google स्थिर मानचित्रों पर वापस आना चाहेंगे या अपने ऐप में एक और नक्शा सेवा जोड़ सकते हैं। यह आप पर निर्भर करता है। – borisdiakur

+0

वैसे भी नहीं है कि मैं इसे Google मानचित्र –