The label on the map when scaling does not remain in place, it begins to shift, if you scale down the label is not specified correctly, did not find anything like this on the subject, Apple, Google, Yandex maps are used. The problem is present at all.

- (YMKAnnotationView *)mapView:(YMKMapView *)aMapView viewForAnnotation:(id<YMKAnnotation>)anAnnotation { if ([[appSettings valueForKey:CAR_MAP_TYPE_KEY] integerValue] == MAPTypeYandex) { static NSString *identefier = @"pointAnotation"; YMKPinAnnotationView *pinView = (YMKPinAnnotationView *)[aMapView dequeueReusableAnnotationViewWithIdentifier:identefier]; if (!pinView) { pinView = [[YMKPinAnnotationView alloc] initWithAnnotation:anAnnotation reuseIdentifier:identefier]; } if (![anAnnotation.title isEqualToString:@"current_location"]) { pinView.image = [UIImage imageNamed:@"location_pin"]; pinView.selectedImage = [UIImage imageNamed:@"location_pin"]; } pinView.annotation = anAnnotation; pinView.canShowCallout = NO; pinView.calloutOffset = CGPointMake(pinView.calloutOffset.x, 20); return pinView; } else { if (![anAnnotation.title isEqualToString:@"current_location"]) { UIView *pinView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"location_pin"]]; DXAnnotationView *annotationView = (DXAnnotationView *)[_mapView dequeueReusableAnnotationViewWithIdentifier:NSStringFromClass([DXAnnotationView class])]; if (!annotationView) { annotationView = [[DXAnnotationView alloc] initWithAnnotation:(id<MKAnnotation>)anAnnotation reuseIdentifier:NSStringFromClass([DXAnnotationView class]) pinView:pinView calloutView:[self createCalloutView] settings:[DXAnnotationSettings defaultSettings]]; } return (YMKAnnotationView *)annotationView; } else { static NSString *annotationIdentifier = @"AnnotationIdentifier"; MKPinAnnotationView *pinView = (MKPinAnnotationView *)[_mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier]; if (!pinView) { pinView = [[MKPinAnnotationView alloc] initWithAnnotation:(id <MKAnnotation>)anAnnotation reuseIdentifier:annotationIdentifier]; [pinView setPinColor:MKPinAnnotationColorGreen]; pinView.animatesDrop = YES; pinView.canShowCallout = NO; } else { pinView.annotation = (id <MKAnnotation>)anAnnotation; } return (YMKAnnotationView *)pinView; } } 

}

  • What code can I see? - Max Mikheyenko
  • it is possible, but there is a lot of it, what exactly is needed from the code ??? it seems that the binding does not go to the desired point, but to the center, I read for JavaScript there is the iconImageOffset property, i.e the point of attachment of the icon to the map, but for ios I can not find anything similar, maybe you know a similar property for ios? - RZzin
  • assuming that the label you have created using MKAnnotation / MKAnnotationView there is not much code there. - Max Mikheyenko
  • Added code, please look - RZzin

1 answer 1

The fact was that I used my own label, and by default its center was in the center of this image. That's why I used the property that the centerOffset has for the custom tag, and I picked up the x and y coordinates so that the picture would hit the right point with a sharp edge. Here is a line from the code:

 pinView.centerOffset = CGPointMake(0, pinView.frame.size.height/4); 

thank