VisioWeb2D 1.8.0

Class

MyNavigationTranslator

Navigation instructions translator

Constructor

new MyNavigationTranslator(pMapviewer, pNavigation, vg_idsopt)

class used to translate navigation instructions coming from the off-line routing engine (needs version 1.7.10 or greater). Takes an instruction array and augments it with plain language descriptions.
Parameters:
Name Type Attributes Description
pMapviewer vg.mapviewer.web.Mapviewer | vg.mapviewer.web2d.Mapviewer
pNavigation object navigate result
vg_ids string <optional>
special array that has correspondance betwee POI ids and their names in an specific format.
Since:
  • 1.7.22 added mapviewer to parameter
See:
Example
var translator = new MyNavigationTranslator();
var languageString = "en"; // "fr"
translator.translateInstructions(routeResultData.navigation.instructions, languageString);

Methods

getIDFromDestinationIndex(destination) → {false|string}

returns the poiID of the destinationIndex of the route. This is important for routes and navigations that do not traverse the given destinations in order, and to get the name of the final destination.
Parameters:
Name Type Description
destination number index
Returns:
false if it cannot be found (for example, destination is a position), or if found, the poiID at a given destination index.
Type
false | string

getPlacenameFromID(poiID) → {false|string}

returns the name of a placeID if known. It looks to see if there is a POI with that ID that has a text if not, it tries to look in the vg_ids object that was passed in the constructor to find that information.
Parameters:
Name Type Description
poiID string
Since:
  • 1.7.22 uses mapviewer.getPOI first to try to get the name of the place first
Returns:
false if it cannot be found, or if the the name of a destination of a given poiID.
Type
false | string
Example
var nearPlaceName = navigationTranslator.getPlacenameFromID(lNearPlaceID);
if (nearPlaceName !== false)
{
...
}

translateInstructions(pInstructions, pLanguageStringopt, mergeFloorChangeInstructionsopt)

translates all the instructions in pInstructions, augmenting each instruction with .brief, .detailed, .duration, .durationInSeconds
Parameters:
Name Type Attributes Default Description
pInstructions Array array of instructions
pLanguageString String <optional>
"en" language string like "en" or "fr", must be in cLanguageMap, defaults to "en" if not found.
mergeFloorChangeInstructions boolean <optional>
false
Since:
  • 1.7.17 updated signature with mergeFloorChangeInstructions