Navigation line in React Maps component

18 Jan 202318 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 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 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.

import { world_map } from 'world-map.ts';
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective, Inject, NavigationLine, NavigationLinesDirective, NavigationLineDirective } from '@syncfusion/ej2-react-maps';
export function App() {
    return(
            <MapsComponent id="element">
                <Inject services={[NavigationLine]} />
                <LayersDirective>
                    <LayerDirective shapeData={world_map}>
                        <NavigationLinesDirective>
                            <NavigationLineDirective visible={true}
                                                     latitude={[37.6276571, -122.4276688]}
                                                     longitude={[-74.0060, -117.7418381]}
                                                     color="black"
                                                     angle={90}
                                                     width={2}
                                                     dashArray="4"/>
                        </NavigationLinesDirective>
                    </LayerDirective>
                </LayersDirective>
            </MapsComponent>
    );
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
import { world_map } from 'world-map.ts';
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective, Inject, NavigationLine, NavigationLinesDirective, NavigationLineDirective } from '@syncfusion/ej2-react-maps';
export function App() {
    return(
            <MapsComponent id="element">
                <Inject services={[NavigationLine]} />
                <LayersDirective>
                    <LayerDirective shapeData={world_map}>
                        <NavigationLinesDirective>
                            <NavigationLineDirective visible={true}
                                                     latitude={[37.6276571, -122.4276688]}
                                                     longitude={[-74.0060, -117.7418381]}
                                                     color="black"
                                                     angle={90}
                                                     width={2}
                                                     dashArray="4"/>
                        </NavigationLinesDirective>
                    </LayerDirective>
                </LayersDirective>
            </MapsComponent>
    );
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);

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 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.
import { world_map } from 'world-map.ts';
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective, Inject, NavigationLine, NavigationLinesDirective, NavigationLineDirective } from '@syncfusion/ej2-react-maps';
export function App() {
    return(
            <MapsComponent id="element">
                <Inject services={[NavigationLine]} />
                <LayersDirective>
                    <LayerDirective shapeData={world_map}>
                        <NavigationLinesDirective>
                            <NavigationLineDirective 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'
                                                    }}/>
                        </NavigationLinesDirective>
                    </LayerDirective>
                </LayersDirective>
            </MapsComponent>
    );
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
import { world_map } from 'world-map.ts';
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapsComponent, LayersDirective, LayerDirective, Inject, NavigationLine, NavigationLinesDirective, NavigationLineDirective } from '@syncfusion/ej2-react-maps';
export function App() {
    return(
            <MapsComponent id="element">
                <Inject services={[NavigationLine]} />
                <LayersDirective>
                    <LayerDirective shapeData={world_map}>
                        <NavigationLinesDirective>
                            <NavigationLineDirective 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'
                                                    }}/>
                        </NavigationLinesDirective>
                    </LayerDirective>
                </LayersDirective>
            </MapsComponent>
    );
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);