Search results

State Persistence in ASP.NET MVC Maps control

State Persistence

State persistence allows the Maps to retain the current modal value in the browser cookies for state maintenance. This action is handled through the enablePersistence property which is set to false by default. When it is set to true, some of the Maps component model values will be retained even after refreshing the page.

razor
persistence.cs
@using Syncfusion.EJ2
@using Syncfusion.EJ2.Maps
@Html.EJS().Maps("container").UseGroupingSeparator(true).Format("n").Load("load").TitleSettings(title => title.Text("Top 50 largest cities in the World").
    TextStyle(new MapsFont { Size = "16px" })).ZoomSettings(new Syncfusion.EJ2.Maps.MapsZoomSettings
      {
          Enable = true
      }).Layers(new List<Syncfusion.EJ2.Maps.MapsLayer>
         {
                    new Syncfusion.EJ2.Maps.MapsLayer
                    {
                        ShapeSettings = new MapsShapeSettings
                        {
                            Fill = "#C1DFF5"
                        },
                        ShapeData = ViewBag.shapeData,
                        MarkerClusterSettings = new MapsMarkerClusterSettings
                        {
                            AllowClustering = true,
                            Shape = MarkerType.Image,
                            Height = 40,
                            Width = 40,
                        },
                        MarkerSettings  = new List<Syncfusion.EJ2.Maps.MapsMarker>
                        {
                            new Syncfusion.EJ2.Maps.MapsMarker
                            {
                                Visible = true,
                                DataSource = ViewBag.ClusterData,
                                Shape=MarkerType.Image,
                                TooltipSettings = new MapsTooltipSettings {
                                    Template = "#template",
                                    Visible = true,
                                    ValuePath= "area",
                                },
                                Height= 20,
                                Width= 20,
                                AnimationDuration= 0,
                            }
                        }}}).Render()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Syncfusion.EJ2.Maps;
using System.Web.Script.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using EJ2MVCSampleBrowser.Models;

namespace EJ2MVCSampleBrowser.Controllers.Maps
{
    public partial class MapsController : Controller
    {
        // GET: MarkerClustering
        public ActionResult MarkerClustering()
        {
            ViewBag.shapeData = this.getWorldMap();
            ViewBag.ClusterData = this.ClusterData();
            return View();
        }
        public object ClusterData()
        {
            string allText = System.IO.File.ReadAllText(Server.MapPath("~/App_Data/MapData/ClusterData.json"));
            return JsonConvert.DeserializeObject(allText, typeof(object));
        }
    }
}