HelpBot Assistant

How can I help you?

Navigation line in Angular Maps component

6 Feb 20266 minutes to read

Navigation lines are curved paths used to denote the route between two locations on the Maps. This feature is commonly used to draw flight routes, sea routes, or any path connecting two geographic points. Navigation lines are enabled by setting the visible property of the navigationLineSettings to true.

Customization

The following properties are available in navigationLineSettings 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 draw a navigation line between two cities on the world map, the latitude and longitude properties are used to specify the start and end points of the navigation line.

import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { MapsModule } from '@syncfusion/ej2-angular-maps'
import { NavigationLineService } from '@syncfusion/ej2-angular-maps'




import { Component, OnInit } from '@angular/core';
import { world_map } from './world-map';

@Component({
imports: [
         MapsModule
    ],

providers: [NavigationLineService],
standalone: true,
    selector: 'app-container',
    template:
    `<ejs-maps id='rn-container' >
    <e-layers>
    <e-layer  [shapeData]= 'shapeData' [navigationLineSettings] = 'navigationLineSettings' ></e-layer>
    </e-layers>
    </ejs-maps>`
})
export class AppComponent implements OnInit {
    public shapeData?: object;
    public navigationLineSettings?: object[];
    ngOnInit(): void {
        this.shapeData = world_map;
        this.navigationLineSettings = [{
            visible: true,
            latitude: [37.6276571, -122.4276688],
            longitude: [-74.0060, -117.7418381],
            color: 'black',
            angle: 90,
            width: 2,
            dashArray: '4'
        }]
    };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

Enabling the arrows

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

  • color - To apply the color for the arrow in the navigation line.
  • offset - To customize the offset position of the arrow in the navigation line.
  • position - To customize the position of the arrow in the navigation line. The possible values are Start and End.
  • size - To customize the size of the arrow in pixels.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { MapsModule } from '@syncfusion/ej2-angular-maps'
import { NavigationLineService } from '@syncfusion/ej2-angular-maps'




import { Component, OnInit } from '@angular/core';
import { world_map } from './world-map';

@Component({
imports: [
         MapsModule
    ],

providers: [NavigationLineService],
standalone: true,
    selector: 'app-container',
    template:
    `<ejs-maps id='rn-container' >
    <e-layers>
    <e-layer  [shapeData]= 'shapeData' [navigationLineSettings] = 'navigationLineSettings' ></e-layer>
    </e-layers>
    </ejs-maps>`
})
export class AppComponent implements OnInit {
    public shapeData?: object;
    public navigationLineSettings?: object[];
    ngOnInit(): void {
        this.shapeData = world_map;
        this.navigationLineSettings = [{
            visible: true,
            latitude: [37.6276571, -122.4276688],
            longitude: [-74.0060, -117.7418381],
            color: 'black',
            angle: 90,
            width: 2,
            dashArray: '4',
            arrowSettings: {
                showArrow: true,
                size: 15,
                position: 'Start'
            }
        }]
    };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));