एनिमेटेड: समाप्त हो गया है जब MKMapView setRegion मुझे कैसे पता कर सकते हैं?

वोट
18

मैं अपने MKMapView पर एक क्षेत्र सेट करें और फिर निर्देशांक नक्शे के पूर्वोत्तर और दप कोने करने के लिए इसी लगाना चाहते हैं।

This code works just fine to do that:
//Recenter and zoom map in on search location
MKCoordinateRegion region =  {{0.0f, 0.0f}, {0.0f, 0.0f}};
region.center = mySearchLocation.searchLocation.coordinate;
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[self.mapView setRegion:region animated:NO]; //When this is set to YES it seems to break the coordinate calculation because the map is in motion

//After the new search location has been added to the map, and the map zoomed, we need to update the search bounds
//First we need to calculate the corners of the map so we get the points
CGPoint nePoint = CGPointMake(self.mapView.bounds.origin.x + mapView.bounds.size.width, mapView.bounds.origin.y);
CGPoint swPoint = CGPointMake((self.mapView.bounds.origin.x), (mapView.bounds.origin.y + mapView.bounds.size.height));

//Then transform those point into lat,lng values
CLLocationCoordinate2D neCoord;
neCoord = [mapView convertPoint:nePoint toCoordinateFromView:mapView];
CLLocation *neLocation = [[CLLocation alloc] initWithLatitude:neCoord.latitude longitude:neCoord.longitude];

CLLocationCoordinate2D swCoord;
swCoord = [mapView convertPoint:swPoint toCoordinateFromView:mapView];
CLLocation *swLocation = [[CLLocation alloc] initWithLatitude:swCoord.latitude longitude:swCoord.longitude];

समस्या मैं मानचित्र ज़ूम एनिमेटेड किया जा चाहते हैं। हालांकि, जब मैं setRegion सेट: हाँ करने के लिए एनिमेटेड, मैं नक्शा जब यह रास्ता ज़ूम आउट किया गया है (यानी, पहले एनीमेशन पूरा हो गया है) से निर्देशांक हो रही अंत। वहाँ किसी भी तरह से एक संकेत है कि एनीमेशन किया जाता है पाने के लिए है?

17/01/2010 को 20:19
का स्रोत उपयोगकर्ता
अन्य भाषाओं में...                            


2 जवाब

वोट
21

कभी MapKit थे, लेकिन MKMapViewDelegate एक विधि है mapView:regionDidChangeAnimated:कि आप जो खोज रहे हैं लग रहा है।

17/01/2010 को 20:38
का स्रोत उपयोगकर्ता

वोट
5

मैं जानता हूँ कि इस सुपर पुराना है, लेकिन सिर्फ मामले में किसी और को एक जवाब की तलाश द्वारा आता है, यहाँ एक विकल्प है।

इस संस्करण के बारे में अच्छी बात यह है कि आप एक पूरा होने एनीमेशन पहले एक के बजाय अनुमान लगा / कॉलबैक विधि में यह हार्डकोड है कि एक अभी भी कहा जाता है के बाद से की पूरा हो गया है सही समय पर चलाया जा सकता है।

[MKMapView animateWithDuration:1.0 animations:^{
    [mapView setRegion:mapRegion animated:YES];
} completion:^(BOOL finished) {
    [UIView animateWithDuration:1.0 animations:^{
        self.mapDotsImageView.alpha = 1.0;
    }];
}];

या केवल

// zoom in...
let km3:CLLocationDistance = 3000
let crTight = MKCoordinateRegionMakeWithDistance(location.coordinate, km3, km3)
MKMapView.animate(withDuration: 1.0, animations: { self.theMap.region = crTight })
30/07/2016 को 00:23
का स्रोत उपयोगकर्ता

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more