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

标签 ios swift maps cartodb carto-mobile

我正在使用 Carto-Mobile,并且尝试使用 CLLocation true hedding 来旋转位置标记,但我无法使其工作。

我为位置标记设置了一个位图图像,它是一个 NTPoint 对象,但是 NTPoint 没有任何根据角度旋转的方法,而不是 NTMarker,我尝试使用 NTMarker 作为位置标记,但在低缩放级别(缩放 6)时永远不会显示真实位置,因此 NTPoint 是更好的选择适合。

所以我希望任何人都可以告诉我如何使用 CARTO-SDK 使用 CLLocation true hedding 来旋转位置标记

问候

最佳答案

以下代码应该可以工作并将图像保持在精确位置:

    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];

关于ios - 如何使用carto-mobile(CARTO-SDK)在ios中旋转位置标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46757053/

相关文章:

javascript - 使用 React Native 进行网络抓取和注入(inject) JavaScript 的最佳方式?

ios - 如何在 textField 上方实现/显示以下弹出窗口?

javascript - 在 HERE map 中将鼠标悬停在标记上时显示内容 Div

GPS 转换 - 像素坐标到 GPS 坐标

ios - 适用于 iOS 的 Ionic 和 Cordova 中的奇怪内存泄漏

ios - SpriteKit 添加 child 不工作

ios - SKSpriteNode 子类化 swift

swift - Swift 按什么顺序计算函数?

ios - 从解析类创建多个 map 注释时出错

r - 使用 qtm tmap 更改图例的语言