0

I am working on developing the cordova HERE map plugin to get route calculation data in app. I am working on adding the functionality for ios. I want to get a maneuver instructions for the route, following is my code to get maneuver instructions for the calculated route.


NSString * language = [[NSLocale preferredLanguages] firstObject]; // getting lang code en

 NSArray* inst= [route instructionsForLanguage:language unitSystem:NMARouteInstructionsUnitSystemMetric];

But I don't know why it is returning empty array. Please help it anyone knows how to get maneuver instructions.

coder
  • 21
  • 1
  • 2

1 Answers1

0

That happening because NSLocale preferredLanguages can give you language code instead of language and country code, for example

[NSLocale preferredLanguages] // -> tr

According to HERE maps documentation function expect language code, like en-US

language should be a valid code according to the IETF BCP-47 standard (see http://tools.ietf.org/html/bcp47 ).

So to make it easier for you, to need to get language code instead.

NSLocale *locale = [NSLocale currentLocale];
NSString *language = [NSString stringWithFormat: "%@-%@", [locale languageCode], [locale countryCode]]; // -> tr-TR
Oleg
  • 591
  • 5
  • 14
  • Thanks @Oleg for your help. But this not solve my problem. I was already getting the language code as 'en' from the code added in question, also tried your code getting same language code 'en' for me and it returns empty array. So i did one thing that I hardcoded the value of language code as 'en-US' and it works for me. Again thanks for your help. – coder Jul 30 '21 at 08:36
  • Let me update my answer then, as it seems that Here maps need to have both code and country code. – Oleg Jul 30 '21 at 13:22
  • hi @oleg. do you know how to implement the NMAMapDataPrefetcherListener in ios sdk. I have created separate question https://stackoverflow.com/questions/68621844/how-to-download-here-map-using-bounding-box-in-here-map-ios-sdk . If you know anything please help me. – coder Aug 03 '21 at 06:36