2

When I try to move my MKPointAnnoatation like this:

[UIView animateWithDuration:0.5 animations:^{
            [user setCoordinate:coordinate];

The pin disappears on the map :( Is there a different solution to move a MKPointAnnotion?

EDIT MORE CODE:

CLLocationCoordinate2D *plotLocation = malloc(sizeof(CLLocationCoordinate2D) *
                                              _trak.trakTagRelationship.count);

    int i=0;
    for (TrakTag* tag in _trak.trakTagRelationship)
    {

        CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(tag.trakTagX.doubleValue,
                                                                           tag.trakTagY.doubleValue);
        plotLocation[i] = coordinate;


        i++;
    }

    TrakTag* dummy = [[_trak.trakTagRelationship allObjects]lastObject];
    CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(dummy.trakTagX.doubleValue,
                                        dummy.trakTagY.doubleValue);

    if (user != NULL)
    {
        [UIView animateWithDuration:0.5 animations:^{
            [user setCoordinate:coordinate];

            NSLog(@"Annotaions:%@",user);

        }];
    }
    else
    {
        user = [[MKPointAnnotation alloc]init];
        [user setCoordinate:coordinate];
        [mapView addAnnotation:user];
    }


    line = [MKPolyline polylineWithCoordinates:plotLocation count:_trak.trakTagRelationship.count];
    [mapView addOverlay:line];
jjuser19jj
  • 1,637
  • 3
  • 20
  • 38
  • Did you try to set coordinate without animation? Does it get worked? – Igor Matyushkin Mar 22 '14 at 16:27
  • without animations I get the same problem – jjuser19jj Mar 22 '14 at 16:46
  • Are you sure that coordinate fits into the visible area? – Igor Matyushkin Mar 22 '14 at 16:49
  • 1
    What is your span and what are the coordinates? – Hermann Klecker Mar 22 '14 at 16:57
  • coordinates are (54.f,8.f) and (55.f,8.f). Yes coordinates fit into the area. – jjuser19jj Mar 22 '14 at 17:02
  • Do you mean latitude 55 and longitude 8? That's in the North Sea west of Denmark. –  Mar 22 '14 at 17:05
  • Jep, those coordinates are "simulated", I am not there at the moment I am testing – jjuser19jj Mar 22 '14 at 17:09
  • What method is this code in? When does it get called? Show more of the surrounding code. You're saying the pin appears at 54,8 (North Sea) and disappears when this code runs? Did you try zooming out to the whole world to confirm the pin is where you think it is? –  Mar 22 '14 at 17:14
  • Is `trakTagRelationship` an `NSSet`? It looks like the code is updating the coordinate to the "last" object in `trakTagRelationship` but if it's an `NSSet`, there is no strict ordering of the objects. You might not always get the last object added to the set (and so the pin is jumping to a previous location that you're not looking at). –  Mar 22 '14 at 17:58
  • Thanks for all your suggestions, I don't know why but after: 1)Resetting the simulator 2)Cleaning Build folder 3)Restarting mac+xcode Everything worked, I should do this sort of thing every time before I ask a question :/ – jjuser19jj Mar 22 '14 at 20:52

0 Answers0