简体   繁体   English

iOS MapBox标注偏移量不起作用,标注始终出现在相同高度

[英]iOS MapBox Callout offset not working, callout always appear at the same height

It seems that despite me providing a value in the offset property for the callout, it still appears at exactly the same position. 似乎尽管我在标注的offset属性中提供了一个值,但它仍然出现在完全相同的位置。 This position is a little too high above the flag images that I am displaying. 这个位置比我要显示的标志图像高一些。

UIImage *markerImage = [UIImage imageNamed:@"Flag.png"]; UIImage * markerImage = [UIImage imageNamed:@“ Flag.png”]; marker = [[RMMarker alloc] initWithUIImage:markerImage anchorPoint:CGPointMake(0.45, 0.9)]; marker = [[RMMarker alloc] initWithUIImage:markerImage anchorPoint:CGPointMake(0.45,0.9)];

marker.calloutOffset = CGPointMake(0, 0.5); marker.calloutOffset = CGPointMake(0,0.5);

//also tried //也尝试过
[marker setCalloutOffset:CGPointMake(0, 0.5)]; [marker setCalloutOffset:CGPointMake(0,0.5)];

marker.canShowCallout = YES; marker.canShowCallout = YES;

marker.delegate = self; marker.delegate =自我;

This is because unlike anchor points in MapBox iOS SDK, callout offset is absolute value, for example if you want to show callout offset at 28 pixels above the the anchor point, you have to set: marker.calloutOffset=CGPointMake(0, 28); 这是因为与MapBox iOS SDK中的定位点不同,标注偏移量是绝对值,例如,如果要在定位点上方28像素处显示标注偏移量,则必须设置: marker.calloutOffset=CGPointMake(0, 28);

if that didn't help, try setting marker.contentsCenter too. 如果那没有帮助,也尝试设置marker.contentsCenter

Hope it helps ;) 希望能帮助到你 ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM