Center position zooming

17 Feb 20222 minutes to read

The center position zooming can be achieved by using the MapsCenterPosition class and ZoomFactor property as mentioned in the following example. The center position is used to configure the zoom level of Maps, and the zoom factor is used to specify the center position where the Maps should be displayed.

@{ 
    var zoom = new Syncfusion.EJ2.Maps.MapsZoomSettings
    {
        Enable = true,
        ZoomFactor = 13
    };
    var centerPosition = new Syncfusion.EJ2.Maps.MapsCenterPosition
    {
        Latitude = 25.5424414701248,
        Longitude = -89.62646484375
    };
}

<div id="map">
    <ejs-maps id="maps" zoomSettings="zoom" centerPosition="centerPosition">
        <e-maps-layers>
            <e-maps-layer shapeData="ViewBag.world_map">
            </e-maps-layer>
        </e-maps-layers>
    </ejs-maps>
</div>
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.world_map = GetWorldMap();
            ViewBag.worldMap = GetMap();
            return View();
        }
        public object GetWorldMap()
        {
            string text = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/WorldMap.json");
            return JsonConvert.DeserializeObject(text);
        }
        public object GetMap()
        {
            string allText = System.IO.File.ReadAllText(Server.MapPath("~/App_Data/WorldMap.json"));
            return JsonConvert.DeserializeObject(allText, typeof(object));
        }
    }
}

Annotation zindex