Open vincentcastagna opened 7 years ago
What language is your device on?
Its in French. But oddly it retrieves me instruction in English.
I'm in debug ... perhaps something to do with that ? I'll try to deploy on playstore to see if I still have the prob
Any ideas ?
Sorry. So it seems not be possible right now. I have to investigate this.
Your package is using that, isn't it ? https://developers.google.com/maps/documentation/directions/intro?hl=en
So I guess that we can have some clues : "If language is not supplied, the API attempts to use the preferred language as specified in the Accept-Language header, or the native language of the domain from which the request is sent"
It depends on what you are using. If you takling about Android and the native API, I indeed use the directions API.
On iOS: https://developer.apple.com/reference/mapkit/mkdirections
Yep sorry did not gave the context.
Well, could it be possible to add some parameters to the TKroute like language preference to pass to the android native API ? I'll try to see if I have time (not sure) to make a PR about this if you think that will be difficult to handle this on your time (and actual contributors)
If this is possible on all platforms, we could do it. If some platforms behave different, for instance if they always use the device language setting, we should not add it into TKRoute
.
Hi, guys on what propertie I found the instrucctions? tanks
@Micnick Check the sample. Everything you need is in TKRoute.
foreach (var s in route.Steps)
{
this.Instructions.Html += string.Format("<b>{0}km:</b> {1}<br /><hr />", s.Distance / 1000,
s.Instructions);
}
@TorbenK Nothing new about this ?
@Umar3x TAnks
the route.Steps propertie is null, how to fill them?
Hello,
@TorbenK have you got any news concerning this demand ? Thanks
The option is just missing in TKCustomMapRenderer, function AddRoute for routeData.
/// <summary>
/// Calculates and adds the route to the map
/// </summary>
/// <param name="route">The route to add</param>
private async void AddRoute(TKRoute route)
{
if (route == null) return;
this._tempRouteList.Add(route);
route.PropertyChanged += OnRoutePropertyChanged;
GmsDirectionResult routeData = null;
string errorMessage = null;
routeData = await GmsDirection.Instance.CalculateRoute(route.Source, route.Destination, route.TravelMode.ToGmsTravelMode(), HERE );
Which could give the optional parameter language present in the GmsDirection.cs
/// <summary>
/// Calculates a route
/// </summary>
/// <param name="origin">The origin</param>
/// <param name="destination">The destination</param>
/// <param name="mode">The travelling mode</param>
/// <param name="language">The language</param>
/// <returns>A <see cref="GmsDirectionResult"/></returns>
public async Task<GmsDirectionResult> CalculateRoute(Position origin, Position destination, GmsDirectionTravelMode mode, string language = null)
{
var response = await _httpClient.GetAsync(this.BuildQueryString(origin, destination, mode, language));
if (response.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<GmsDirectionResult>(await response.Content.ReadAsStringAsync());
}
return null;
}
I'm going to do a PR about this. When is the next release planned ? Thanks.
Hello,
I have sucessfully implemented routes and getting instructions well ... but I need to display instructions in French ? Is it possible to change instructions language retrieved from API ?
Thanks