代码之家  ›  专栏  ›  技术社区  ›  Randy Hector

如何使用carto mobile(carto-SDK)在ios中旋转位置标记

  •  0
  • Randy Hector  · 技术社区  · 7 年前

    我正在使用Carto Mobile,我正在尝试使用旋转位置标记 CLLocation 真的,但我做不到。

    我将位图图像设置为位置标记,它是一个 NTPoint 对象,但是 NTPoint公司 NTMarker ,我尝试使用 NTMarker公司 对于位置标记,但在低缩放级别(缩放6)下,从不显示真实位置,因此 NTPoint公司 更合适。

    所以我希望任何人都能告诉我如何使用 使用CARTO-SDK的true hedding

    当做

    1 回复  |  直到 7 年前
        1
  •  0
  •   JaakL    7 年前

    以下代码应起作用,并将图像保持在精确位置:

        NTMarkerStyleBuilder *builder = [[NTMarkerStyleBuilder alloc]init];
    
        // anchor 0,0 means that image is rotated from the center
        // you may have different anchor point depending on graphics
        [builder setAnchorPointX:0 anchorPointY:0];
    
        self.positionMarker = [[NTMarker alloc] initWithPos:position style:[builder buildStyle]];
    
       ...
       // rotate marker, depending on marker graphics
       // "180-course" is ok if it is "arrow down"
       // additional adjustment is for mapView rotation, image keeps
       // here correct course even if map is rotated
    
      double course = location.course;
      [self.positionMarker setRotation: 180 - course - self.contentView.mapView.getRotation];