Search results

Localization in ASP.NET MVC Maps control

Localization library allows you to localize the default text content of maps. Maps has the static text for some features such as zooming toolbars and the text can be changed to any culture (Arabic, Deutsch, French, etc.) by defining the locale value and translation object.

Locale key words Text to display
Zoom Zoom
ZoomIn ZoomIn
ZoomOut ZoomOut
Reset Reset
Pan Pan
ResetZoom Reset Zoom

To load translation object in an application, use the load function of L10n class.

For more information about localization, refer to localization

razor
localization.cs
@using Syncfusion.EJ2;
@using Syncfusion.EJ2.Maps;
@Html.EJS().Maps("maps").Locale("ar-AR").Layers(l => {
    l.ShapeData(ViewBag.usmap).Add();
}).ZoomSettings(zs=>zs.Enable(true)).Render()

<script>
    ej.base.L10n.load({
        'ar-AR': {
            'maps': {
                ZoomIn: 'تكبير',
                ZoomOut: 'تصغير',
                Zoom: 'زوم',
                Pan: 'مقلاة',
                Reset: 'إعادة تعيين'
            },
        }
    });
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;

namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            ViewBag.usmap = GetUSMap();
            ViewBag.electionData = GetElectionData();
            return View();
        }
        public object GetUSMap()
        {
            string allText = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/usMap.js");
            return JsonConvert.DeserializeObject(allText);
        }
        public object GetElectionData()
        {
            string text = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/electiondata.js");
            return JsonConvert.DeserializeObject(text);
        }
    }
}