Class: NavBar

cercaliagl.control/NavBar


Javascript ES5

const control = new cercaliagl.control.NavBar();

Class for nav bar control which offers to search addresses, calculate routes and search points. This class can be obtained via map object.

All autocomplete components element gets addresses by country priority depends where map is centered. It is possible to access to some functionalities by published methods listed in this page.

To access to NavBar control element you can do it:

const map = new cercaliagl.Map({ target: 'map', controls: [cercaliagl.control.MapControls.NAVBAR] });
const navbarControl = map.getControlByName(cercaliagl.control.MapControls.NAVBAR);

new NavBar()

Extends

Methods

Clear all navbar autocomplete inputs.

Returns cercalia Map object

Returns:
Cercalia map.

getClass(){string} inherited

Get class name.

Returns:
Class name.

getElement(){Element} inherited

Get control HTML Element

Returns:
HTML Element

Get control id.

Returns:
Id.

getMap(){module:maplibre-gl~Map} inherited

Returns mapboxgl Map object

getName(){string|null} inherited

Get control name. Null if control has not defined name.

Returns:
Class name.

Get autocomplete search address service object. More details: module:cercaliagl/service/Autocomplete~Autocomplete.

Returns:
Autocomplete service.

Hide control.

hideButton(buttonName)

Show button form UI element. Buttons available to show/hide are for widgets: search address, calculate route, search POIs. You can access this values via constants. Show buttonName parameter description.

Name Type Description
buttonName string

Button to hide on NavBar control. Possible values:

  • cercaliagl.control.NavBar.Buttons.ADDRESS
  • cercaliagl.control.NavBar.Buttons.POIS
  • cercaliagl.control.NavBar.Buttons.ROUTING

Reset menu to initial state.

setAutocompleteAddressCallback(fn)

Set custom callback function for address search. Set null to disable custom function and use default. This is useful if user wants to override default behaviour. Unique parameter received is GeEntity.

Example usage:

navBarControl.setAutocompleteAddressCallback(function(data) {
  const country = data.country.value;
  const municipality = data.municipality.value;
  const coordX = parseFloat(data.coord.x);
  const coordY = parseFloat(data.coord.y);
  console.log(country, municipality, coordY + ',' + coordX);
});
Name Type Description
fn function | null

Callback function. null to use default API behaviour.

setCoordinatesSearchCallback(fn)

Set custom callback function for coordinates search, same behaviour as customAutocompleteAdressCallback. Set null to disable custom function and use default.

Name Type Description
fn function | null

Callback function. null to use default API behaviour.

Show control.

showButton(buttonName)

Show button form UI element. Buttons available to show/hide are for widgets: search address, calculate route, search POIs. You can access this values via constants. Show buttonName parameter description.

Name Type Description
buttonName string

Button to show on NavBar control. Possible values:

  • cercaliagl.control.NavBar.Buttons.ADDRESS
  • cercaliagl.control.NavBar.Buttons.POIS
  • cercaliagl.control.NavBar.Buttons.ROUTING