Search results

Multilayer in ASP.NET Core Maps control

15 Oct 2021 / 1 minute to read

The multilayer support allows loading multiple shape files in a single container and enables Maps to display more information. The shape layer is the main layer of the Maps. Multiple layers can be added in a shape layer as SubLayer using the Type property.

multilayer.cs
Copied to clipboard
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;
using Syncfusion.EJ2.Charts;

namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            ViewBag.usa = GetUSMap();
            ViewBag.california = GetCaliforniaMap();
            ViewBag.texas = GetTexasMap();
            return View();
        }
        public object GetUSMap()
        {
            string text = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/USA.json");
            return JsonConvert.DeserializeObject(text);
        }
        public object GetCaliforniaMap()
        {
            string text = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/California.json");
            return JsonConvert.DeserializeObject(text);
        }
        public object GetTexasMap()
        {
            string text = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/Texas.json");
            return JsonConvert.DeserializeObject(text);
        }
    }
}

Adding multiple layers in the Map