Navigation lines

30 Sep 20224 minutes to read

The navigation lines are used to denote the path between two locations. This feature can be used to draw flight or sea routes. Navigation lines are enabled by setting the Visible property of the MapsNavigationLine to true.

Customization

The following properties are available in MapsNavigationLine to customize the navigation line of the Maps component.

  • Color - To apply the color for navigation lines in Maps.
  • DashArray - To define the pattern of dashes and gaps that is applied to the outline of the navigation lines.
  • Width - To customize the width of the navigation lines.
  • Angle - To customize the angle of the navigation lines.
  • HighlightSettings - To customize the highlight settings of the navigation line.
  • SelectionSettings - To customize the selection settings of the navigation line.

To navigate the line between two cities on the world map, Latitude and Longitude values are used to indicate the start and end points of navigation lines drawn on Maps.

@using Syncfusion.EJ2;
@Html.EJS().Maps("maps").LegendSettings(legend=> legend.Visible(true)).Layers(l =>
{
    l.NavigationLineSettings(ns => {
        ns.Visible(true).Latitude(new double[] { 40.7128, 36.7783})
        .Longitude(new double[] { -74.0060, -119.4179 }).Color("black").Angle(90)
        .Width(4).DashArray("4").Add();
    }).ShapeData(ViewBag.worldmap).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;

namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            ViewBag.worldmap = GetWorldMap();
            return View();
        }
        public object GetWorldMap()
        {
            string allText = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/WorldMap.js");
            return JsonConvert.DeserializeObject(allText);
        }
    }
}

Maps with navigation line

Enabling the arrows

To enable the arrow in the navigation line, set the ShowArrow property of MapsArrow to true. The following properties are available in MapsArrow to customize the arrow of the navigation lines.

  • Color - To apply the color for arrow of the navigation line.
  • OffSet - To customize the offset position of the arrow of the navigation line.
  • Position - To customize the position of the arrow in navigation line. The possible values can be Start and End.
  • Size - To customize the size of the arrow in pixels.
@using Syncfusion.EJ2;
@Html.EJS().Maps("maps").LegendSettings(legend => legend.Visible(true)).Layers(l =>
{
    l.NavigationLineSettings(ns =>
    {
        ns.Visible(true).Latitude(new double[] { 40.7128, 36.7783 })
        .Longitude(new double[] { -74.0060, -119.4179 }).Color("black").Angle(90)
        .Width(4).DashArray("4").ArrowSettings(new Syncfusion.EJ2.Maps.MapsArrow
        {
            ShowArrow = true,
            Size = 15,
            Position = "Start",
        }).Add();
    }).ShapeData(ViewBag.worldmap).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;

namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            ViewBag.worldmap = GetWorldMap();
            return View();
        }
        public object GetWorldMap()
        {
            string allText = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/WorldMap.js");
            return JsonConvert.DeserializeObject(allText);
        }
    }
}

Enabling the arrow