Search results

Layers

The maps is maintained through layers, and it can accommodate one or more layers.

Multilayer

The multilayer support allows you to load multiple shape files in a single container. This enables maps to display more information.

Adding multiple layers to the maps

The shape layers are the core layers of a map. The multiple layers can be added in the shape layers as subLayers within the shape layers.

Sub Layer

The subLayer is the collection of shape layers.

In this example, the world map shape is used as shape data by utilizing the “WorldMap.json” file in the following folder structure obtained from downloaded Maps_GeoJSON folder.

..\ Maps_GeoJSON\

Refer both shape data and shape settings as illustrated in the following code example.

razor
layers.cs
@using Syncfusion.EJ2;
@Html.EJS().Maps("maps").Layers(l =>
{
    l.ShapeData(ViewBag.worldmap).ShapeSettings(new { fill= "#9CBF4E", border=new
    {
        width = 0.5,
        color = "White"
    }}).Add();
    l.ShapeData(ViewBag.usmap).ShapeSettings(new { fill = "orange", border = new
        {
            width = 1,
            color = "White"
        }
    }).Add();
}).Render()
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.worldmap = GetWorldMap();
            ViewBag.usmap = GetUSMap();
            return View();
        }
        public object GetUSMap()
        {
            string allText = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/USA.json");
            return JsonConvert.DeserializeObject(allText);
        }
        public object GetWorldMap()
        {
            string text = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/WorldMap.json");
            return JsonConvert.DeserializeObject(text);
        }
    }
}

Refer the API for Layers feature.