Skip to content

Commit

Permalink
GoogleMap should respect Culture language
Browse files Browse the repository at this point in the history
  • Loading branch information
enchev committed Oct 21, 2024
1 parent e812ff1 commit 54269ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Radzen.Blazor/RadzenGoogleMap.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
if (firstRender)
{
await JSRuntime.InvokeVoidAsync("Radzen.createMap", Element, Reference, UniqueID, ApiKey, MapId, Zoom, Center,
data.Select(m => new { Title = m.Title, Label = m.Label, Position = m.Position }), Options, FitBoundsToMarkersOnUpdate);
data.Select(m => new { Title = m.Title, Label = m.Label, Position = m.Position }), Options, FitBoundsToMarkersOnUpdate, Culture.TwoLetterISOLanguageName);
}
else
{
await JSRuntime.InvokeVoidAsync("Radzen.updateMap", UniqueID, null, null,
data.Select(m => new { Title = m.Title, Label = m.Label, Position = m.Position }), Options, FitBoundsToMarkersOnUpdate);
data.Select(m => new { Title = m.Title, Label = m.Label, Position = m.Position }), Options, FitBoundsToMarkersOnUpdate, Culture.TwoLetterISOLanguageName);
}
}

Expand Down
13 changes: 7 additions & 6 deletions Radzen.Blazor/wwwroot/Radzen.Blazor.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ window.Radzen = {
}
}
},
loadGoogleMaps: function (defaultView, apiKey, resolve, reject) {
loadGoogleMaps: function (defaultView, apiKey, resolve, reject, language) {
resolveCallbacks.push(resolve);
rejectCallbacks.push(reject);

Expand All @@ -204,6 +204,7 @@ window.Radzen = {

script.src =
'https://maps.googleapis.com/maps/api/js?' +
(language ? 'language=' + language + '&' : '') +
(apiKey ? 'key=' + apiKey + '&' : '') +
'callback=rz_map_init&libraries=marker';

Expand All @@ -217,7 +218,7 @@ window.Radzen = {

document.body.appendChild(script);
},
createMap: function (wrapper, ref, id, apiKey, mapId, zoom, center, markers, options, fitBoundsToMarkersOnUpdate) {
createMap: function (wrapper, ref, id, apiKey, mapId, zoom, center, markers, options, fitBoundsToMarkersOnUpdate, language) {
var api = function () {
var defaultView = document.defaultView;

Expand All @@ -226,7 +227,7 @@ window.Radzen = {
return resolve(defaultView.google);
}

Radzen.loadGoogleMaps(defaultView, apiKey, resolve, reject);
Radzen.loadGoogleMaps(defaultView, apiKey, resolve, reject, language);
});
};

Expand All @@ -246,10 +247,10 @@ window.Radzen = {
});
});

Radzen.updateMap(id, zoom, center, markers, options, fitBoundsToMarkersOnUpdate);
Radzen.updateMap(id, zoom, center, markers, options, fitBoundsToMarkersOnUpdate, language);
});
},
updateMap: function (id, zoom, center, markers, options, fitBoundsToMarkersOnUpdate) {
updateMap: function (id, zoom, center, markers, options, fitBoundsToMarkersOnUpdate, language) {
var api = function () {
var defaultView = document.defaultView;

Expand All @@ -258,7 +259,7 @@ window.Radzen = {
return resolve(defaultView.google);
}

Radzen.loadGoogleMaps(defaultView, apiKey, resolve, reject);
Radzen.loadGoogleMaps(defaultView, apiKey, resolve, reject, language);
});
};
api().then(function (google) {
Expand Down

0 comments on commit 54269ab

Please sign in to comment.