3

I am working on a vehicle tracking app using Here maps. I want to rotate the marker icon (NMAMapMarker) in the Here maps to a specific angle according to turn taken by the vehicle (similar to Uber app). Earlier I used Google maps, marker in Google maps provides a rotation property to rotate the marker to a specific angle. Is there any similar property available in Here maps?

Is there any update for this Nokia Here maps Navigation marker orientation

Thank you

  • 1
    I don't understand why this question gets a downvote. Before putting a downvote against this question kindly add a comment to enlighten me why you think this question qualifies for a downvote. That will definitely improve my question in the future. – Aravind Bhuvanendran Oct 18 '19 at 11:43
  • 1
    upvote as I think it's relevant question – Tomas Oct 18 '19 at 12:00
  • you probably got a downvote because the question basically duplicates the question you linked. – Scriptable Oct 18 '19 at 12:07
  • @Scriptable I understand but it was asked 3 years back in Android. Here maps added new features to their SDK after that. – Aravind Bhuvanendran Oct 18 '19 at 12:16
  • I didn't leave the downvote, but you said you didn't understand why so I tried to explain. The SDK does not provide the functionality you want, so you may need to look at some of the older workarounds and come up with your own solution for iOS – Scriptable Oct 18 '19 at 12:18
  • Yeah @scriptable . I figured out a solution. Thanks for the comment. – Aravind Bhuvanendran Oct 19 '19 at 02:36

1 Answers1

0

In general it is not possible to rotate NMAMapMarker, Within HERE iOS Premium SDK the default Position indicator NMAPositionIndicator has the property tracksCourse which would rotate the indicator with the heading available from device.

The alternative would be to use NMAMapLocalModel as also mentioned in the comments above

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