Search results

State Persistence in ASP.NET Core 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.

tagHelper
persistence.cs
@{       
        var titleStyle = new MapsFont
        {
            Size = "16px",
        };
        var cluster = new MapsMarkerClusterSettings
        {
            AllowClustering=true,
            Shape= Syncfusion.EJ2.Maps.MarkerType.Image,
            Height=40,
            Width=40,
            ImageUrl="../styles/images/maps/cluster.svg",
            LabelStyle= new MapsFont {
                Color="White"
            }

        };
        var tooltip = new MapsTooltipSettings
        {
            Visible = true,
            ValuePath = "city"
        };

     }
    <div class="control-section">
        <ejs-maps id="maps" format="n" useGroupingSeparator="true">
            <e-maps-titlesettings alignment="@Syncfusion.EJ2.Maps.Alignment.Center" text="Top 50 largest cities in the World" textStyle="titleStyle"></e-maps-titlesettings>
            <e-maps-zoomsettings enable="true"></e-maps-zoomsettings>
            <e-maps-layers>
                <e-maps-layer shapeData="ViewBag.world" markerClusterSettings="cluster">
                    <e-layersettings-shapesettings fill="#C1DFF5"></e-layersettings-shapesettings>
                    <e-layersettings-markers>
                        <e-layersettings-marker visible="true" shape="Image" imageUrl="../styles/images/maps/ballon.png" height="20" width="20" animationDuration="0" tooltipSettings="tooltip" dataSource="ViewBag.marker"></e-layersettings-marker>
                    </e-layersettings-markers>
                </e-maps-layer>
            </e-maps-layers>
        </ejs-maps>
    </div>
    }
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));
        }
    }
}