VisioWeb2D 1.8.0

Class

MyNavigation

Navigation example class.

Constructor

new MyNavigation(pMapViewer, pNavigationData, vg_ids)

It allows the rendering of navigation instructions if available from computeRoute(). Creates a navigation object to simplify the display of instructions. It uses for the media directory the value of vg.imagePath (by default "../media"), which contains:
  • images for transit instructions: transit_*.png
Parameters:
Name Type Description
pMapViewer vg.mapviewer.Mapviewer
pNavigationData object result of vg.mapviewer.Mapviewer.computeRoute()
vg_ids object place id name correspondance, using the same file format as ids.json: {"targets":["default"],"labels":{"UL0-ID0003":["UL0-ID0003","Zara"],...} }
Since:
  • 1.7.18 added ID of waypoints and destination
See:
Examples
This class asummes that the following elements exist on your .html file

<div id="instructions" class="instructions">
	<div id="instructions_prev_button" class="instructions"><img src="media/leftArrow.png"/></div>
	<div id="instructions_count" class="instructions"></div>
	<div id="instructions_brief" class="instructions"></div>
	<div id="instructions_detail" class="instructions"></div>
	<img id="instructions_icon" class="instructions"></img>
	<div id="instructions_time" class="instructions"></div>
	<div id="instructions_next_button" class="instructions"><img src="media/rightArrow.png"/></div>
</div>
pNavigationData will have the form

{ "navigation": {
 "instructions" : [{
	"icon": "transit_instruction_turn_left.png",
	"dataset": "0",
	"modality": "pedestrian",
	"time": "0.000000",
	"totalTime": "45.953415","position" : { "lat" : "48.782332", "lon" : "2.221195" },
	"detail": "Go straight for a few seconds then turn left",
	"brief": "Go straight",
	"duration": " for a few seconds"
  }
  ,...
  ]
}

Members

(static) navigationInstructionRadius :number

radius in meters to use when moving the camera to the beginning of an instruction.

Methods

displayNextInstruction()

displays the previous instruction if possible and move the camera to the start of the instruction

displayPrevInstruction()

displays the previous instruction if possible and move the camera to the start of the instruction

isValid() → {boolean}

returns false if there was no navigation data (for example missing "computeNavigation: true" in the routing request)
Returns:
false if there was no navigation data
Type
boolean

remove()

clear all information associated with the navigation.

removeInstructionOverlays()

clear any instruction extra overlays.