2

我正在使用 Here maps 开发车辆跟踪应用程序。我想根据车辆转弯(类似于优步应用程序)将 Here 映射中的标记图标(NMAMapMarker)旋转到特定角度。早些时候我使用谷歌地图,谷歌地图中的标记提供了一个旋转属性来将标记旋转到一个特定的角度。Here地图中是否有类似的属性?

此诺基亚 Here 地图导航标记方向是否有任何更新

谢谢

4

1 回答 1

0

通常,无法旋转 NMAMapMarker,在 HERE iOS Premium SDK 中,默认的位置指示器 NMAPositionIndicator 具有属性 trackCourse,它将使用设备提供的标题旋转指示器。

另一种方法是使用 NMAMapLocalModel ,如上面的评论中所述

   ... 
   NMAFloatMesh *mesh = [[NMAFloatMesh alloc] init];

    float size = 5.0f;

    float vertices[4 * 3] = {-size / 2,   -size/2, 0.0f,
        -size/2,   size / 2, 0.0f,
        size / 2,   -size/2, 0.0f,
        size/2,   size/2, 0.0f,
    };

    [mesh setVertices:vertices withCount:4];

    float textureCoordinates[4 * 2] = {0.0,  0.0,
        0.0,  1.0,
        1.0,  0.0,
        1.0,  1.0};

    [mesh setTextureCoordinates:textureCoordinates withCount:4];

    short triangles[2 * 3] = {2, 1, 0,
        1, 2, 3};

    [mesh setTriangles:triangles withCount:2];

    _customPosIndicator = [[NMAMapLocalModel alloc] initWithMesh:mesh];

    NMAImage *image = [NMAImage imageWithUIImage:[UIImage imageNamed:@"256-256-pin2.png"]];

    /*
     // To load svg file as a custom position indicator, please use this code.
     NSBundle* main = [NSBundle mainBundle];
     NSString *resourcePath = [main pathForResource:@"tracker-1093167" ofType:@"svg"];

     NSLog(@"resourcePath: %@", resourcePath);
     NSData *resourceData = [NSData dataWithContentsOfFile:resourcePath];
     NMAImage *image = [NMAImage imageWithData:resourceData];
     */

    [_customPosIndicator setAutoscaled:true];
    [_customPosIndicator setTexture:image];
    [_customPosIndicator setCoordinates:[NMAGeoCoordinates alloc]];

    self.mapView.positionIndicator.displayObject = _customPosIndicator;

    self.mapView.positionIndicator.visible = true;

    ...

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(nonnull CLHeading *)newHeading {
    NSLog(@"%f", newHeading.magneticHeading);
    if(_customPosIndicator != nil){
        [_customPosIndicator setYaw:newHeading.magneticHeading];
    }
}
于 2020-01-20T13:11:05.420 回答