Search results

Navigation Lines in ASP.NET MVC Maps control

Navigation lines are used to denote the path between the two locations. You can use this feature to draw the navigation lines for flight, train or sea routes.

Customization

You can customize the following properties in the navigation lines by modifying their default values in navigationlineSettings

  • Color - Specifies the color of navigation line.
  • Dash array - Specifies the type of dash array line.
  • Width - Specifies the line width.
  • Angle - Specifies the navigation line angle.
  • Highlight settings - Customizes the opacity, border, and fill color when the cursor hovers over it.
  • Selection settings - Customizes the opacity, border, and fill color when the line is selected.

The following example shows rendering the path between two locations using latitudes and longitudes.

You can customize the navigation line color, dashArray, width and angle by modifying their default values in navigationLineSettings.

Refer to the following code sample to navigate the line between two cities in World map. Provide two locations latitude and longitude values to navigationLineSettings.

razor
navigation-line.cs
@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);
        }
    }
}

Enabling the arrows

You can enable the arrows in the navigation line using arrowSettings.showArrow API, also you can customize following properties in arrow

  • color - Specifies the color of the arrow
  • offset - Specifies the arrow’s offset position
  • position - Specifies the arrow position to start or end line
  • size - Specifies the arrow size in pixel
razor
arrow.cs
@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({ 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);
        }
    }
}

Refer to the API for Navigation Lines feature.