문제

I'm using the MapBox SDK for iOS and encountered a problem I can't find a good solution for. In the iOS the MKAnnotationView allows me to do the following:

        view.centerOffset = CGPointMake(0, -15);

Is there a MapBox RMMarker equivalent for this?

So basically I need to move the marker a few pixels up from its original position, taking the zoom level into account as well. (So when you zoom, the marker's bottom part keeps fixed on the same point)

As you can guess, there's a little arrow at the bottom of my marker that I want to have pointing to the GPS position in question, but the RMMarker seems to center on this point right now rather than being positioned on top of it, like I'd need.

도움이 되었습니까?

해결책

On mapbox it's proportional bwn 0 - 1.0;

So if we want it centered it would be

CGPointMake(0.5, 0.5);

Use this:

- (id)initWithUIImage:(UIImage *)image anchorPoint:(CGPoint)anchorPoint

RMMarker * marker = [RMMarker initWithUIImage:[UIImage imageNamed:@"yourImage.png"] anchorPoint:CGPoint(0.5,1.0)];   

If you want the bottom of the image to point to the location, I think you'd want either 1.0 or -1.0 as your Y point. I don't have a MapBox proj available right here to test it.

See Docs Here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top