Uncenter MkMapView

szavazat
0

Próbálom „uncenter” a térképet, és távolítsa el az összes kommentárokat. ennek az az oka, hogy a mapView fogja használni más nézetet vezérlők megjelenítéséhez különböző jelölések és a helyszínek. Mi történik most, hogy én vagyok a „eltávolítás kommentárok” módszer, és én eltávolítja őket, de a térképen marad középpontja a helyszínen és így amikor az új jelölés jönnek, nem mozog. Van egy módja annak, hogy állítsa vissza a régióban, és ha igen, milyen értéket restelheti azt. Próbáltam nulla, nulla és néhány kiszámított érték, de „core animáció” azt mondja, hogy az összes érvénytelen. hogyan jutok, hogy a kicsinyítés, majd vissza, én új jelölések?

itt van néhány kód

-(void)recenterMap {

NSArray *coordinates = [_mapView valueForKeyPath:@annotations.coordinate];
CLLocationCoordinate2D maxCoord = {-90.0f, -180.0f};
CLLocationCoordinate2D minCoord = {90.0f, 180.0f};

//NSLog(@%@, [coordinates description]);

for (NSValue *value in coordinates) {
    CLLocationCoordinate2D coord = {0.0f, 0.0f};
    [value getValue: &coord];

    if(coord.longitude > maxCoord.longitude) {
        maxCoord.longitude = coord.longitude;
    }

    if(coord.latitude > maxCoord.latitude){

        maxCoord.latitude = coord.latitude;
    }

    if(coord.longitude < minCoord.longitude){
        minCoord.longitude = coord.longitude;
    }

    if(coord.latitude < minCoord.latitude){
        minCoord.latitude = coord.latitude;
    }
}


MKCoordinateRegion region = {{0.0f, 0.0f}, {0.0f, 0.0f}};
region.center.longitude = (minCoord.longitude + maxCoord.longitude) / 2.0;
region.center.latitude = (minCoord.latitude + maxCoord.latitude) / 2.0;
region.span.longitudeDelta = maxCoord.longitude - minCoord.longitude;
region.span.latitudeDelta = maxCoord.latitude - minCoord.latitude;


[_mapView setRegion: region animated: YES];
}

Amit a centrikus Methos én vagyok segítségével

- (MKAnnotationView *)mapView: (MKMapView *)mapView viewForAnnotation: (id <MKAnnotation>)annotation{

MKAnnotationView *view = nil;
if(annotation != mapView.userLocation){

    Annotation *schoolAnn = (Annotation*)annotation;
    view = [self.mapView dequeueReusableAnnotationViewWithIdentifier:@schoolLoc];
    if(nil == view){
        view = [[[MKPinAnnotationView alloc] initWithAnnotation:schoolAnn     reuseIdentifier:@schoolLoc]autorelease];
    }

    [(MKPinAnnotationView *)view setAnimatesDrop:YES];
    [view setCanShowCallout:YES];

}
else { 
    [self recenterMap];
}

return view;
}

Ez a „más” darab várakozik, amíg a kék márvány csepp majd recenters a térképen. A baj az, hogy ez a rész, hogy mikor megy vissza az előző nézet Controller i távolítsa el az összes jelöléseket, így mikor jön vissza a Felhasználói hely (valamilyen okból) nem ugrik vissza. Hogyan jutok ez a pop vissza?

Előre is köszönöm srácok

A kérdést 08/01/2010 13:03
a forrás felhasználó
Más nyelveken...                            


1 válasz

szavazat
0

Megvan az első rész, tette kicsinyítés ismét csak egy funkció tettem, hogy állítsa be a régióban fel, hogy az USA-ban.

-(void)unCenterMap{

MKCoordinateRegion region2 = {{0.0f, 0.0f}, {0.0f, 0.0f}};
region2.center.longitude = (-98.151855); //coordinate for approximately the center of the US
region2.center.latitude = 39.402244;
region2.span.longitudeDelta = 3.0;
region2.span.latitudeDelta = 3.0;


[_mapView setRegion: region2 animated: YES];

}

A második rész még mindig elgondolkodtató, hogyan jutok arra a helyre, hogy a pop újra?

Válaszolt 11/01/2010 10:24
a forrás felhasználó

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