Πώς μπορώ να ξέρω πότε 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