Constructor
new Mapviewer()
It is the main entry point to initialize, update and control the map view.
Members summary
Name | Description |
---|---|
camera | Returns the camera object that allows the user to change the pitch or rotation of the map. |
cameraDrivenExplorer | member responsible for the camera-driven exploration which consists of setting the current building based on where the camera is pointed at. |
cameraNorthRotation | Indicates the rotation (in degrees) needed to align the map with the true north. This parameter is valid once the map is done initializing. |
isAccelerated | Indicates if the mapviewer uses hardware acceleration (WebGL). If it is not accelerated it is strongly recommended to setup a vertical view and disable pitch manipulation |
lodFactor | Controls the amount of detail that is visible at a given height. A value of 2.0 shows at a given altitude, the amount of detail that would be seen if one was twice as close to the ground. Valid values are positive numbers. Default 1.0 |
minimumDataSDKVersion | Used to determine if data is too old to be read by this SDK this is the minimum data version the SDK can read. |
multiBuildingView | member responsible for managing the view manipulations when dealing with multi-building maps. |
navigationTranslator | member responsible for managing the languages available for navigation instructions. |
revision | Internal revision of SDK. |
sdkType | returns "web", to differentiate from VisioWeb2D |
version | Internal version of SDK. |
Methods summary
Name | Description |
---|---|
addFloorLink | This method allow to add a Link to the scene which will link two points on two different floors, links on the same floor will not be displayed as well as when two floors are positioned at the same height. The difference of Links with respect to Paths, is that Links are camera facing and are attached to two different floors. |
addPath | This method allow to add a path to the scene. Note: all points should have the same .z otherwise the track may not be flat. |
addPOI | This method allow to add a POI Object in the scene. The POI is visible by default after creation. |
animateValue | Interpolates a value, calling the step function each time, and the complete function at the end. It uses the same frame rate as the mapviewer; it is a better choice than jQuery.animate since it uses requestAnimationFrame() and is synchronised with viewer. step function will only be called once per frame. Makes important difference in low-end devices. The animation starts right away. |
computeDistance | Computes the distance in meters between two points. |
computeHeadingAngle | Computes the horizontal heading angle, in degrees, between pPointStart-pPivotPoint and pPointEnd-pPivotPoint. It will ignore any .z component. |
computeRoute | Computes a route, use addPath() to add it once computed. |
convertLatLonToPoint | Converts a lat/lon point to a local point. The local point can be used with visioweb.Camera#goTo function or visioweb.Mapviewer#addPath. |
convertPointToLatLon | Converts a local point to a lat/lon point. |
convertPointToScreen | Converts a local point to a screen coordinate. for example {x: .., y:.., optionally z} to a screen coordinate {left: ...,top: ...} |
convertScreenToPoint | Converts a pixel coordinate to a local point. For example {left: ..., top: ....} to {x: .., y:.., z: 0} To use this local point as a camera position for use with camera.goTo or camera.position, one needs to add a .radius |
destroy | This method calls unload API, destroys the view and ultimately, the mapviewer instance. |
destroyView | This method destroys the view-related objects, removes listeners and stops rendering. |
generatePOIClusters | Given an array of points, generates a hierarchy of clusters to unclutter the scene and preserve rendering performances. Important:Points should belong to the same floor. If they don't, the first point's floor is taken as reference and points belonging to other floors will be ignored. |
getCurrentFloor | Returns the current floor name. |
getExtraData | Returns any extra data embedded in the map (e.g. venue layout). |
getFloors | Retrieve the floor objects. |
getFootprint | This method retrieves one or more footprint(s) for an ID if it exists. |
getFootprintPoints | This method retrieves the footprint(s) of a given ID |
getFootprints | This method retrieves all footprints that are on the map. If there is no footprint data on the map, there will be no keys on the result. |
getLoaderStatistics | Used to determine how many textures and models are pending to be loaded as well if there is a requestRedraw |
getLogStatistic | returns true if statistics logger is enabled, false otherwise. |
getLogStatistic | returns returns an url or undefined |
getLogStatisticAppID | returns a string or false |
getMapName | Returns the map name in the form domain/map |
getPlace | This method retrieves a pickable element according to its ID. |
getPlaceIcon | This method returns the place icon url that has been set for the given place id, using setPlaceIcon API. |
getPlaceName | This method returns the place name that has been set for the given place id, using setPlaceName API. |
getPlaces | This method retrieves all interactive surfaces. This is equivalent to calling getPlace() on all existing ids. If the id is not unique, the returned place is undefined, i.e. it could be different from what you would get on getPlace(id). Usually it should be called once, and the results cached on the page. |
getPOF | This method retrieve the point of focus associated with an ID if it exists. A Point of Focus enables the map owner to insert some additionnal information into the map for a given ID. It has no representation on the final rendering but brings some position and orientation information which can be useful for camera manipulations. |
getPOFs | This method retrieves all points of focus that are on the map. |
getPOI | returns an Array of all POI instances related to that ID. For a given POI ID, there can be several representations (icons, texts, potentially appearing on several LODs) hence several POI instances. |
getPOIs | returns a dictionary in which each key is a POI ID and each value is an array of POI instances. For a given POI ID, there can be several representations (icons, texts, potentially appearing on several LODs) hence several POI instances. |
getRoutingAttributes | Returns all the routing attributes that are present in the routing database if available. Its result can be used as a parameter to computeRoute pRouteRequest.routingParameters.excludedAttributes It can return for example ["stairs","lift","access","virutal"], note that "virtual" and "access" are internal attributes, not to be used. |
getRoutingModalities | Returns all the routing modalities that are present in the routing database if available, for example ["pedestrian","shuttle"] Can be used as a parameter to computeRoute pRouteRequest.routingParameters.excludedModalities |
getRoutingNode | It can be used for example to determine if an ID or position is routable, if not, then one could disable a Returns non-false if the place or position is routable. The result of this function can be passed to computeRoute as pRouteRequest.src or pRouteRequest.dst. In the future, this can include a hint to speed up the computeRoute. route button for that ID. |
getViewpointPosition | Computes a viewpoint position {x, y, radius} which centers the point on the padded viewport. If there is only one position (options.points.length == 1), this method preserves the current camera altitude and orientation. |
graphicsLoading | Used to determine if textures and models are loaded. |
hide | Method to hide the mapviewer's container. It also calls mapviewer.stop() to halt rendering. |
initialize | This method is called to load and setup a Mapviewer object. Calling this method is equivalent to calling load and setupView APIs successively: |
initStatistics | initializes the statistics instance |
isInside2D | Determines if a point {x:,y:} is inside a polygon (Array of points), ignore z attribute. |
isInsideFootprint | Determines if a point {x:,y:} is inside the footprint or one of the footprints for a given POI id. |
load | This method is called to load and parse map data. After calling this method, the mapviewer instance won't be ready to run yet, setup API needs to be called to complete the initialization. See initialize for more information about the parameters. Triggers loadCompleted if it succeeds, loadFailed otherwise. Listening to loadCompleted or using the .then() callback, developers can add some tasks requiring map data, before starting to render the map. It can prove useful to use map data (for instance the routing network) without actually displaying the map. |
off | similar to jQuery off, used to remove event listeners |
offsetPosition | Offsets a position with a distance in meters given a direction. |
on | similar to jQuery on, used to add event listeners.
You can listen to the mapviewer defined events, or you can listen to your own (for which you will have to trigger them). Events triggered by VisioWeb: - lifecycle: 'loadCompleted', 'loadFailed', 'initializeCompleted', 'initializedFailed' - render: 'redraw', 'resize' - interactivity: 'mouseup', 'routeComputed', 'exploreStateChanged', 'exploreStateWillChange' If the handler returns false, other subsequent handlers will not be called. |
once | similar to jQuery once, used to add event listeners that will only be executed once, and automatically removed after execution. If the handler returns false, other subsequent handlers will not be called. |
queryNearPlaces | finds all the places that are near a position within a certain threshold. uses the position.alt or position.floor to figure out what layer to search on |
requestRedraw | request the map to be redrawn and will trigger the calling of the postRenderListener's |
resetPlaceColor | Restores the original color for a placeObject, thus removing a potential highlight or temporary color. |
resize | Resize map. The container should have been resized beforehand. If percentage size is used, then it is the integrator's responsibility to call the resize() function at every resize. Note when resizing the amount of visible map will not change (assuming no change in aspect ratio). The mapviewer.camera.maxRadius will not change either. |
setAutoUpdateLOD | Auto update LOD will change the LOD of the current Floor as a function of the
camera distance. If you are enabling LODs by hand, it is best to disable
auto update LODs. Default true |
setLanguage | Change locale for venue. |
setLogStatistic | set Log Statistics flag. |
setLogStatisticAppID | set Log Statistics appID. |
setLogStatisticURL | set Log Statistics url. |
setPlaceColor | Set a place color (as highlight, or temporarily). |
setPlaceIcon | Set a place icon.
The icon will have a fixed orientation except when the camera "switches" sides, at which point the icon will be flipped (the orientation changes 180 degrees). |
setPlaceName | Set a place name by updating all of its labels.
All labels (text) will be updated.
If an icon shares the same ID and label is not empty it will be ignored.
The label will have a fixed orientation except when the camera "switches" sides, at which point the label is flipped (the orientation changes 180 degrees).
NOTE: on IE10 this function is very expensive. Avoid rendering all the labels. |
setSkybox | allows developer to initialize a skybox using either a single strip image |
setTrackingEnabled | set position tracking on a POI. |
setupMultiBuildingView | Setup listeners and UI/UX for MultiBuilding management. Instantiates visioweb.MultiBuildingView and visioweb.CameraDrivenExplorer and exposes them through Mapviewer's multiBuildingView and cameraDrivenExplorer properties. |
setupNavigationTranslator | Instantiates visioweb.NavigationTranslator and exposes it through Mapviewer's navigationTranslator property. |
setupView | This method can be called before or after load. It configures several organs of the viewer like the camera, the renderer and the event handlers. |
show | Method to show the mapviewer's container. It also calls mapviewer.start() to restart rendering. |
start | This method must be called when the HTML document is loaded in order to start the rendering. Should be called as late as possible to minimize unnecessary screen refreshes. |
stop | This method must be called when the application wishes to stop rendering, for instance when unloading a map. |
trigger | trigger an event type. It will execute all triggers ordered by type, stopping if any handler returns exactly false |
unload | This method unloads all map data and resources. |
Members detail
camera :visioweb.Camera
Returns the camera object that allows the user to change the pitch or rotation of the map.
cameraDrivenExplorer :visioweb.CameraDrivenExplorer
member responsible for the camera-driven exploration which consists of
setting the current building based on where the camera is pointed at.
cameraNorthRotation :number|false
Indicates the rotation (in degrees) needed to align the map with the true north.
This parameter is valid once the map is done initializing.
- Since:
- 1.7.3
- See:
Example
mapviewer.camera.heading = mapviewer.cameraNorthRotation; // camera points to the top of the canvas in VisioMapEditor
mapviewer.camera.rotation = 0; // camera points to the top of the canvas in VisioMapEditor
mapviewer.camera.heading = 0; // camera points to the north
mapviewer.camera.rotation = mapviewer.cameraNorthRotation; // camera points to the north
isAccelerated :boolean
Indicates if the mapviewer uses hardware acceleration (WebGL).
If it is not accelerated it is strongly recommended to setup a vertical view and disable pitch manipulation
- Deprecated:
- Yes
Example
if (!mapviewer.isAccelerated)
{
mapviewer.camera.pitch = -90;
mapviewer.camera.pitchManipulatorEnabled = false;
// we can allow rotation.
//mapviewer.camera.rotationManipulatorEnabled = false;
}
lodFactor :number
Controls the amount of detail that is visible at a given height. A value of 2.0 shows at
a given altitude, the amount of detail that would be seen if one was
twice as close to the ground. Valid values are positive numbers. Default 1.0
minimumDataSDKVersion :string
Used to determine if data is too old to be read by this SDK
this is the minimum data version the SDK can read.
- Since:
- 1.7.15
multiBuildingView :visioweb.MultiBuildingView
member responsible for managing the view manipulations when dealing with
multi-building maps.
navigationTranslator :visioweb.NavigationTranslator
member responsible for managing the languages available for navigation instructions.
revision :string
Internal revision of SDK.
sdkType :string
returns "web", to differentiate from VisioWeb2D
- Since:
- 1.7.15
version :string
Internal version of SDK.
Methods detail
addFloorLink(options) → {visioweb.Link|false}
This method allow to add a Link to the scene which will link two points on two different floors,
links on the same floor will not be displayed as well as when two floors are positioned at the same height.
The difference of Links with respect to Paths, is that Links are camera facing and are attached to two different floors.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Since:
- 1.9.7 renamed into addFloorLink
- See:
Returns:
a Link or false.
- Type
- visioweb.Link | false
addPath(options) → {visioweb.Path|false}
This method allow to add a path to the scene. Note: all points should have the same .z otherwise the track may not be flat.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Since:
- 1.7.16 added options.overlay
- See:
Returns:
a path or false.
- Type
- visioweb.Path | false
addPOI(options) → {visioweb.POI}
This method allow to add a POI Object in the scene.
The POI is visible by default after creation.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Since:
- 1.9.7 If called before loadCompleted or initializeCompleted, the options will be stored as pending and the actual call will happen when the initialization is complete.
- See:
Returns:
or null if it could not create one.
- Type
- visioweb.POI
Examples
// For text that zooms in and out
// which you could also control the visibility (with ramp functions)
// use 'text' and 'url' fields
// use onObjectMouseUp to get a callback on click
selected_poi = mapviewer.addPOI({
url: "test.png",
text: 'The object "'+element.vg.id+'" has been clicked',
position: {x: element.vg.position.x, y: element.vg.position.y, z: 10},
id: 'mypoi',
onObjectMouseUp: function() {alert('click');},
scale: 6
});
// For constant size text with full css/html control
// use 'selector' which overlays a <div> over the map.
<div style="display: none;">
<div id="test" style="font-weigth: bold; font-size: 24px; color: #fff; background: none;"\>
</div>
</div>
...
selected_poi = mapviewer.addPOI({
selector: '#test',
position: {x: element.vg.position.x, y: element.vg.position.y, z: 10},
});
animateValue(fromValue, toValue, options) → {false|Object}
Interpolates a value, calling the step function each time, and the complete function at the end. It uses the same frame rate as the mapviewer; it is a better choice than jQuery.animate since it uses requestAnimationFrame() and is synchronised with viewer.
step function will only be called once per frame.
Makes important difference in low-end devices. The animation starts right away.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fromValue |
number | ||||||||||||||||||||||||||
toValue |
number | ||||||||||||||||||||||||||
options |
Object | (they are very similar to jQuery.animate)
Properties
|
- Since:
- 1.7.21 added default value for duration.
Returns:
Object if it started the animation. the Object.stop() can be used to stop the animation.
- Type
- false | Object
Example
// example animate the pitch to go down in one second
var animation = mapviewer.animateValue(mapviewer.camera.pitch,-85,{
duration: 1000,
step: function(pitch) {
mapviewer.camera.pitch = pitch;
},
complete: function() {
alert('update UI');
}
});
// you can also stop the animation.
animation.stop();
* @example
* @example
// animate the position of a POI
var poi_image = mapviewer.addPOI({
url:'../media/test.png',
position: {x:0, y:0, z:0},
alignment: {x: 0, y: 1},
overlay: true
});
var animation = mapviewer.animateValue(0,100, {
duration: 2000, // 2 seconds
step: function(value) {
var position = poi_image.options('position');
position.x = value;
poi_image.options('position', position);
},
complete: function() {
alert('animate completed');
},
stop: function() {
alert('animate stopped');
}
});
// animation.stop();
computeDistance(pStartPoint, pPointEnd) → {number}
Computes the distance in meters between two points.
Parameters:
Name | Type | Description |
---|---|---|
pStartPoint |
localPoint | point containing .x, .y, and possibly .z |
pPointEnd |
localPoint | point containing .x, .y, and possibly .z |
- Since:
- 1.7.18
- See:
Returns:
distance in meters between the two points
- Type
- number
computeHeadingAngle(pPivotPoint, pPointStart, pPointEnd) → {number|false}
Computes the horizontal heading angle, in degrees, between pPointStart-pPivotPoint and pPointEnd-pPivotPoint. It will ignore any .z component.
Parameters:
Name | Type | Description |
---|---|---|
pPivotPoint |
localPoint | The local pivot point |
pPointStart |
localPoint | The local start point |
pPointEnd |
localPoint | The local end point |
- Since:
- 1.7.16
- See:
Returns:
heading angle in degrees [0,360], values are "clockwise". It returns false if the distance between pPivotPoint and a point is 0.
- Type
- number | false
Examples
// Suppose you want to compute if mytargetposition is in front/left/right/behind of myposition relative to myheading
var myposition = {x: 0, y: 0, z:0}
var myheading = 10; // approx north... mapviewer.getPOF('web').headingInDegrees
var mytargetposition = {x: 10, y: 10, z:0}; // or say 2nd position of instruction: mapviewer.convertLatLonToPoint(instruction.positions[1])
var headingAngle = mapviewer.computeHeadingAngle(myposition, mapviewer.offsetPosition(myposition,myheading,0,10), mytargetposition);
// ... headingAngle > 315 or < 45, go forward; between 45 and 135 go right...
// validate visually
mapviewer.addPOI({position: myposition, text: 'O', scale: 5})
mapviewer.addPOI({position: mytargetposition, text: 'T', scale: 5})
mapviewer.addPOI({position: mapviewer.offsetPosition(myposition,myheading,0,10), text: 'i', scale: 5})
// suppose you wanted to compute the heading between two lat/lon positions
function computeHeading(startPosition,endPosition) {
var startPoint = mapviewer.convertLatLonToPoint(startPosition);
var endPoint = mapviewer.convertLatLonToPoint(endPosition);
northPoint = mapviewer.offsetPosition(startPoint,0,0,10);
return mapviewer.computeHeadingAngle(startPoint,northPoint,endPoint);
}
computeRoute(pRouteRequest) → {Promise}
Computes a route, use addPath() to add it once computed.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pRouteRequest |
Object | An object used containing the route being requested. It should also include callbacks for success and error.
Properties
|
- Since:
- 1.7.19 updated firstNodeAsIntersection parameter to include first node after waypoint. Navigation instructions can have .attributes parameter including floor transition attributes for next edge: "stairway","escalator", and "lift"
- See:
Returns:
where then(fulfilled(), rejected()) callbacks can be added.
rejected() will be called if src/dst is missing or if dst == src, or if there is a problem accessing the server. The result attributes are shown in the example.
- Type
- Promise
Examples
Compute a route that only takes elevators (i.e. avoids stairs and escalators)
mapviewer.computeRoute({
src: "161",
dst: "1",
// include this line for handicap routing.
routingParameters: { excludedAttributes: [ "stairway", "escalators" ] },
})
.then(function({request,data}) { ... })
.catch(function(e) { ... });
Compute a route with navigation, but minimal number of instructions
mapviewer.computeRoute({
src: "161",
dst: "1",
computeNavigation: true,
navigationParameters: {
"firstNodeAsIntersection": true,
"mergeFloorChangeInstructions": true,
"modalityParameters": {
"pedestrian" : { "straightAngleThreshold" : 180.0, "nearPlacesThreshold": 4} }
}
})
.then(function({request,data}) { ... })
.catch(function(e) { ... });
The result will have the following attributes:
{
"request": { computeRoute request parameters..."src": ... "dst": ... }
"legs": [{
"dataset": "B3-UL00",
"modality": "pedestrian",
"destinationIndex": 0,
"points": [{
"lat": 45.74095,
"lon": 4.88094,
}, ...],
"height": 0 // in meters
}],
"destinationIndices": [0,1], // array of actual order the destinations are visited, will have length 1 for 'closest', and length will be >= 1 for all.
"length": 35.10, // in meters
"duration": 31.58, // in seconds
"status": 200, // 200 means success, 404 not found, 500 internal error
"sdkVersion": "1.7.16",
"navigation": {
"route": { ... this same object, used for having access to route, and route.request, when looking at navigation}
"instructions": [{
"positions": [{
"lat": 45.74095,
"lon": 4.88094,
},...],
"position": {
"lat": 45.74095,
"lon": 4.88094,
},
"height": 0,
"modality": "pedestrian",
"dataset": "B3-UL00",
"destinationIndex": 0, // useful if route had multiple destinations
// but not visited in order.
"time": 0, // in in seconds of the start of the instructions
"length": 6.624, // in meters
"duration": 5.96, // in seconds
"maneuverType": "eVgManeuverTypeTurnRight", // see MyNavigation
"nearPlaces": [{ // array of IDs/distance/angle from the end point of the instruction.
"id": "B3-UL01-ID0071",
"distance": 6.623932, // distance in meters from the
"angle": 180
}, ...],
"actionAngle": 88, // angle of change of direction of the end of the instruction
"totalTime": 31.58, // total time of the whole navigation
"icon": "transit_instruction_turn_right.png" // see MyNavigation
...
"attributes": ["lift"] // could also be "stairway", or "escalator"
}, ...],
"parameters": { // navigation parameters passed in.
"modalityParameters": {
"shuttle": {
"straightAngleThreshold": 180,
"distanceFromCouloirThreshold": 1000
}
},
"algorithm": "auto",
"mergeFloorChangeInstructions": true // reduce number of instructions:
// e.g. avoid issuing single instruction to change floor.
},
}
}
// to find the closest ID (using routes, not as the crow flies distance)
// like closest toilet
// you would need to create a destination array of all the toilet IDs
mapviewer.computeRoute({src: 'B2-UL0-ID0087', // could be the result of getRoutingNode()
dst: ['B4-UL05-ID0028','B4-UL05-ID0027','B4-UL05-ID0029'], // could be the result of getRoutingNode() use .id to find out place id.
destinationOrder: 'closest'})
.then(function({request,data}){
console.log('closest id:'+request.dst[data.destinationIndices[0]].id);
});
convertLatLonToPoint(pWGS84) → {localPoint}
Converts a lat/lon point to a local point.
The local point can be used with visioweb.Camera#goTo function or visioweb.Mapviewer#addPath.
Parameters:
Name | Type | Description |
---|---|---|
pWGS84 |
WGS84 | The Lat/Long object to be converted { lat:, lon: }. |
Returns:
The converted local point object { x:, y:, z:}. If the projection is invalid, the local point will be {x: 0, y: 0, z: 1, valid: false}.
- Type
- localPoint
convertPointToLatLon(pPoint) → {WGS84}
Converts a local point to a lat/lon point.
Parameters:
Name | Type | Description |
---|---|---|
pPoint |
localPoint | The local point to be converted, { x:, y:, z:} |
Returns:
The converted lat/lon point, { lat:, lon:}. The projection is invalid, the points will be {lat: 0, lon: 0, valid: false}
- Type
- WGS84
convertPointToScreen(local) → {ScreenPoint}
Converts a local point to a screen coordinate.
for example {x: .., y:.., optionally z} to a screen coordinate {left: ...,top: ...}
Parameters:
Name | Type | Description |
---|---|---|
local |
pPoint | point object { x:, y:, optionally z:} |
- Since:
- 1.7.11
Returns:
object {left:, top: }, {left: 0, top: 0} being top left corner of map container
- Type
- ScreenPoint
convertScreenToPoint(pScreenPosition, optionalZopt) → {localPoint}
Converts a pixel coordinate to a local point.
For example {left: ..., top: ....} to {x: .., y:.., z: 0}
To use this local point as a camera position for use with camera.goTo or camera.position,
one needs to add a .radius
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pScreenPosition |
ScreenPosition | The .left/.top of the pixel over the container, {left:0,top:0} being top left corner of the container | ||
optionalZ |
number |
<optional> |
0 | height of the searched point |
- Since:
- 1.7.11
- See:
Returns:
The converted local point object { x:, y:, z:}. If the projection is invalid, the local point will be {x: 0, y: 0, z: 1, valid: false}.
- Type
- localPoint
destroy() → {Promise}
This method calls unload API, destroys the view and ultimately, the mapviewer instance.
Returns:
resolves when the map was properly unloaded and the view properly destroyed.
- Type
- Promise
destroyView() → {Promise}
This method destroys the view-related objects, removes listeners and stops rendering.
- Since:
- 1.9.7
Returns:
resolves when the view was properly destroyed.
- Type
- Promise
generatePOIClusters(points, optionsopt) → {Array.<visioweb.POICluster>}
Given an array of points, generates a hierarchy of clusters to unclutter the scene and preserve rendering performances.
Important:Points should belong to the same floor.
If they don't, the first point's floor is taken as reference and points belonging to other floors will be ignored.
Important:Points should belong to the same floor.
If they don't, the first point's floor is taken as reference and points belonging to other floors will be ignored.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
points |
Object | the input key/value array of points. Keys are point IDs, values are point Objects (see below). | ||||||||||||||||||||||||||||||||||||||||||||||||||||
point.poi |
visioweb.POI | the point's associated POI object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
point.properties |
Object |
<optional> |
the point's properties that are needed by the optional reducer. | |||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
the options for cluster generation.
Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
poiOptions.url |
string | function |
<optional> |
../media/cluster.png | the URL to an image file. | ||||||||||||||||||||||||||||||||||||||||||||||||||
poiOptions.scale |
string | function |
<optional> |
the scale to apply to the POI object. | |||||||||||||||||||||||||||||||||||||||||||||||||||
poiOptions.zoomScaleFactor |
string | function |
<optional> |
to enable zoomScaleFactor (if set, scale will be ignored). | |||||||||||||||||||||||||||||||||||||||||||||||||||
poiOptions.selector |
Object |
<optional> |
false | To display POIClusters using HTML content rather than a simple image. If not false, all other poiOptions will be ignored. Properties
|
- Since:
- 1.9.1
- See:
Returns:
An array of POICluster objects. An empty array in case of failure.
- Type
- Array.<visioweb.POICluster>
getCurrentFloor() → {string}
Returns the current floor name.
Returns:
- Type
- string
getExtraData() → {Object|false}
Returns any extra data embedded in the map (e.g. venue layout).
- Since:
- 1.7.17
Returns:
returns any extra data embedded in the map (e.g. venue layout) or false otherwise
- Type
- Object | false
getFloors() → {Array.<visioweb.Floor>}
Retrieve the floor objects.
- Since:
- 1.7.10 added .heightMin and .heightMax to floor structure.
Returns:
Array of floor objects which have attribute .name (string), .index (number) and if available
.heightMin (number) and .heightMax (number)
- Type
- Array.<visioweb.Floor>
getFootprint(id) → {Object|Array.<object>|false}
This method retrieves one or more footprint(s) for an ID if it exists.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | the place id. e.g. "L250" |
- Since:
- 1.7.19 added .floor attribute to result.
- See:
Returns:
single object or array of objects of the form {id, floor, points}
- Type
- Object | Array.<object> | false
getFootprintPoints(id) → {Array.<Object>|false}
This method retrieves the footprint(s) of a given ID
Parameters:
Name | Type | Description |
---|---|---|
id |
string | the place id. e.g. "L250" |
- Since:
- 1.8.3 this method is useful when the footprint is needed to compute viewpoint rather than interiority
- See:
Returns:
object containting all points of all footprints
- Type
- Array.<Object> | false
getFootprints()
This method retrieves all footprints that are on the map. If there is no footprint data on the map, there will be no keys on the result.
- Since:
- 1.7.22
- See:
Returns:
Object with keys being the IDs and each value being the footprint object containting attributes .id, .floor, and .points: array of points.
You should not modify the result of this function.
You should not modify the result of this function.
getLoaderStatistics() → {Object}
Used to determine how many textures and models are pending to be loaded as well if there is a requestRedraw
- Since:
- 1.7.19
- See:
Returns:
with .models, .textures, and .requestRedraw (this will be true if a new frame is requested to be drawn, e.g. camera position changed or model has been loaded but not rendered)
- Type
- Object
Example
// you could put this inside mapviewer.initialize(...).done() or mapviewer.on('initializeCompleted',...)
mapviewer.on('initializeCompleted', function(ev) {
function checkLoading() {
var stats = mapviewer.getLoaderStatistics();
console.log('pending models: '+stats.models + ', textures: '+stats.textures + ' requestRedraw: '+ stats.requestRedraw);
if (!mapviewer.graphicsLoading())
{
mapviewer.off('redraw', checkLoading);
alert('everything is loaded');
}
}
mapviewer.on('redraw', checkLoading);
});
getLogStatistic() → {boolean}
returns true if statistics logger is enabled, false otherwise.
- Since:
- 1.9.0
Returns:
- Type
- boolean
getLogStatistic() → {boolean}
returns returns an url or undefined
- Since:
- 1.9.0
Returns:
- Type
- boolean
getLogStatisticAppID() → {string}
returns a string or false
- Since:
- 1.9.0
Returns:
- Type
- string
getMapName() → {string|false}
Returns the map name in the form domain/map
- Since:
- 1.8.9
Returns:
- Type
- string | false
getPlace(id) → {visioweb.Place|false}
This method retrieves a pickable element according to its ID.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | the place id. e.g. "L250" |
Returns:
The place object if it exists, false otherwise.
placeObjects also have the following read-only members: vg.floor, vg.id and, vg.originalColor and vg.position.
- Type
- visioweb.Place | false
getPlaceIcon(id) → {string|Array.<string>|false}
This method returns the place icon url that has been set for the given place id, using setPlaceIcon API.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | the place id. e.g. "L250" |
- Since:
- 1.9.6
Returns:
The place icon url (or urls if there are several) or false if none was set.
- Type
- string | Array.<string> | false
getPlaceName(id) → {string|Array.<string>|false}
This method returns the place name that has been set for the given place id, using setPlaceName API.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | the place id. e.g. "L250" |
- Since:
- 1.9.6
Returns:
The place name (or names if there are several) or false if none was set.
- Type
- string | Array.<string> | false
getPlaces() → {Object.<string, visioweb.Place>}
This method retrieves all interactive surfaces.
This is equivalent to calling getPlace() on all existing ids.
If the id is not unique, the returned place is undefined, i.e. it could be different from what you would get on getPlace(id).
Usually it should be called once, and the results cached on the page.
This is equivalent to calling getPlace() on all existing ids.
If the id is not unique, the returned place is undefined, i.e. it could be different from what you would get on getPlace(id).
Usually it should be called once, and the results cached on the page.
- Since:
- 1.8.6 renamed getAllPlaces into getPlaces
- See:
Returns:
An associative array containing all Place objects.
Keys are the IDs and each value is the associated Place, holding a vg property with the following attributes: floor, id, originalColor, position and radius.
Keys are the IDs and each value is the associated Place, holding a vg property with the following attributes: floor, id, originalColor, position and radius.
- Type
- Object.<string, visioweb.Place>
getPOF(id) → {Object|false}
This method retrieve the point of focus associated with an ID if it exists.
A Point of Focus enables the map owner to insert some additionnal information into the map for a given ID.
It has no representation on the final rendering but brings some position and orientation information which can be useful for camera manipulations.
A Point of Focus enables the map owner to insert some additionnal information into the map for a given ID.
It has no representation on the final rendering but brings some position and orientation information which can be useful for camera manipulations.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | the place id. e.g. "L250" |
- Since:
- 1.8.6 renamed getPoint into getPOF
- See:
Returns:
a point of focus containing attributes: .id, .x, .y, .headingInDegrees, .height, and .floor.
- Type
- Object | false
getPOFs() → {Object.<string, object>}
This method retrieves all points of focus that are on the map.
- Since:
- 1.8.6 renamed getPoints into getPOFs
- See:
Returns:
An associative array containing all points of focus.
Keys are the IDs and each value is the associated point of focus with the following attributes: id, x, y, headingInDegrees, .height, and .floor.
You should not modify the result of this function.
Keys are the IDs and each value is the associated point of focus with the following attributes: id, x, y, headingInDegrees, .height, and .floor.
You should not modify the result of this function.
- Type
- Object.<string, object>
getPOI(id) → {Array.<visioweb.POI>|undefined}
returns an Array of all POI instances related to that ID.
For a given POI ID, there can be several representations (icons, texts, potentially appearing on several LODs)
hence several POI instances.
For a given POI ID, there can be several representations (icons, texts, potentially appearing on several LODs)
hence several POI instances.
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
- Since:
- 1.8.6 renamed getPoi into getPOI
Returns:
An array of POI objects. You should not modify this array.
- Type
- Array.<visioweb.POI> | undefined
getPOIs() → {Object.<string, Array.<visioweb.POI>>}
returns a dictionary in which each key is a POI ID and each value is an array of POI instances.
For a given POI ID, there can be several representations (icons, texts, potentially appearing on several LODs)
hence several POI instances.
For a given POI ID, there can be several representations (icons, texts, potentially appearing on several LODs)
hence several POI instances.
- Since:
- 1.8.6 renamed getPois into getPOIs
Returns:
A collection containing all POI objects. You should not modify these arrays.
If initialization is not complete, this method will not return visioweb.POI instances but their options instead.
If initialization is not complete, this method will not return visioweb.POI instances but their options instead.
- Type
- Object.<string, Array.<visioweb.POI>>
getRoutingAttributes() → {Array.<string>|false}
Returns all the routing attributes that are present in the routing database if available.
Its result can be used as a parameter to computeRoute pRouteRequest.routingParameters.excludedAttributes
It can return for example ["stairs","lift","access","virutal"], note that "virtual" and "access" are internal attributes, not to be used.
- Since:
- 1.7.10
- See:
Returns:
an array of modality names or false if it does not support this operation.
- Type
- Array.<string> | false
getRoutingModalities() → {Array|false}
Returns all the routing modalities that are present in the routing database if available, for example ["pedestrian","shuttle"]
Can be used as a parameter to computeRoute pRouteRequest.routingParameters.excludedModalities
- Since:
- 1.7.10
- See:
Returns:
an array of modality names or false if it does not support this operation.
- Type
- Array | false
getRoutingNode(placeOrPosition, parametersopt) → {RouteNodeObject|false}
It can be used for example to determine if an ID or position is routable, if not, then one could disable a
Returns non-false if the place or position is routable.
The result of this function can be passed to computeRoute as pRouteRequest.src or pRouteRequest.dst.
In the future, this can include a hint to speed up the computeRoute.
route button for that ID.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
placeOrPosition |
string | RoutePosition | id (e.g. "129") of the start point or position {"lat": x, "lon": y, "alt": z} or {"lat": x, "lon": y, "floor": floorname} or {x:, y:, floor/alt:} | ||
parameters |
RoutingNodeParameters |
<optional> |
{option: 'onEdge',threshold: 200} | {option: 'anyNode'|'onEdge', distanceThreshold: N, excludeModalities: ['shuttle']} |
- Since:
- 1.7.21 update doc about attributes get getting a routing node from a position.
- See:
Returns:
returns a RouteNodeObject which can be used as a src or dst parameter to computeRoute, or false if it is not routable.
It can be of the form {id: poiID, floor: string } if computed from a poiID or
{ position: inputPosition, routePosition: positionOnRoutingNetwork, floor: string } if computed from a position.
The .id attribute can be used after computing a multi-point route to determine the poiID of the third destinatin: routePatameters.dst[2].id
- Type
- RouteNodeObject | false
Examples
// go from your current position to a shop L250
var cameraPosition = mapviewer.camera.position;
var cameraPositionLatLng = mapviewer.convertPointToLatLon({x: cameraPosition.x, y: cameraPosition.y });
var srcNode = mapviewer.getRoutingNode({lat: cameraPositionLatLng.lat,
lon: cameraPositionLatLng.lon,
floor: mapviewer.getCurrentFloor() });
var dstNode = mapviewer.getRoutingNode('L250');
if (srcNode !== false && dstNode !== false)
{
mapviewer.computeRoute({
src: srcNode,
dst: dstNode,
})
.then(function({request,data}) { ... })
.catch(function(e) { ... });
} else {
.. figure out if the error is on the srcNode or dstNode and inform the user...
}
// you can look at .floor, and .id if getting routing node from ID.
mapviewer.getRoutingNode('1')
=> { "id": "1", "floor": "0", "_hint": private }
// you can look at .floor, .position (position used for the search), and .routePosition (position on routing network) if getting routing node from position.
mapviewer.getRoutingNode({x: 0.5, y: 0.5, alt: 0 })
=> { "floor": "0", "position": { x: 0.5, y: 0.5, z: 0}, "routePosition": { x: 0.21, y: 0.32, z: 0 }, "_hint": private }
getViewpointPosition(options) → {Object}
Computes a viewpoint position {x, y, radius} which centers the point on the padded viewport.
If there is only one position (options.points.length == 1), this method preserves the current camera altitude and orientation.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Since:
- 1.7.17 added options.pitch and options.heading
Returns:
camera position object (Attributes .x, .y and .radius) or false if input position not valid (missing x and y)
- Type
- Object
Examples
// suppose you have a transparent overlay menu overlaps 200 pixels the right of the map.
// getViewpointPosition can be used to compute a viewpoint such that certain positions
// do not "land" on margin areas.
var viewpointPosition = mapviewer.getViewpointPosition({
points: [{x: ..., y: ..., z: ...}],
top: 10,
bottom: 10,
left: 10,
right: 200
);
mapviewer.camera.position = viewpointPosition;
// or
mapviewer.multiBuildingView.goTo({viewpoint: {position: viewpointPosition}});
// Suppose you want to recenter the camera because you have a 200 pixel status bar on the bottom of the map
var viewpoint_options = { points: [mapviewer.camera.position], bottom: 200};
mapviewer.camera.position = mapviewer.getViewpointPosition(viewpoint_options);
graphicsLoading() → {boolean}
Used to determine if textures and models are loaded.
- Since:
- 1.9.7 replaced isLoaded by graphicsLoading (reversed logic) to avoid confusion with map data loading process.
- See:
Returns:
true if there are still pending models or textures to be loaded at this instance.
- Type
- boolean
Example
function checkLoadedGraphics() {
if (!mapviewer.graphicsLoading())
{
mapviewer.off('redraw', checkLoadedGraphics)
alert('everything is loaded');
}
}
mapviewer.on('redraw', checkLoadedGraphics);
hide()
Method to hide the mapviewer's container.
It also calls mapviewer.stop() to halt rendering.
initialize(mapDiv, parametersopt) → {Promise}
This method is called to load and setup a Mapviewer object.
Calling this method is equivalent to calling load and setupView APIs successively:
Calling this method is equivalent to calling load and setupView APIs successively:
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mapDiv |
DOM | The DOM element where the Mapviewer will render itself. It is used to obtain the size of the map. To avoid being able to see bubbles when they are outside the maps, its CSS should have 'overflow': 'hidden' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
parameters |
Object |
<optional> |
A parameter object supporting the following values:
Properties
|
- Since:
- 1.7.22 fixed label batched optimization, and option to disable it (use parameters.optimizations.nobatch=true)
- See:
-
- visioweb.Mapviewer#trigger. Switched behavior for parameters.path, if it is .svg, search .svg first then fallback to .json, for people who have new SDK but have not updated their data.
- visioweb.Mapviewer#load
- visioweb.Mapviewer#setup
Returns:
where then(fulfilled(), rejected()) callbacks can be added.
- Type
- Promise
Example
mapviewer.initialize(container, parameters)
.then(function() {
(...)
mapviewer.start();
})
<=>
mapviewer.load(parameters)
.then(function() {
// here we can do something before rendering the map
mapviewer.setupView(container)
.then(function() {
(...)
mapviewer.start();
});
});
initStatistics()
initializes the statistics instance
- Since:
- 1.9.7
isInside2D(point, polygon) → {boolean}
Determines if a point {x:,y:} is inside a polygon (Array of points), ignore z attribute.
Parameters:
Name | Type | Description |
---|---|---|
point |
Object | |
polygon |
Array | array of points |
- Since:
- 1.8.3
Returns:
true if point is inside polygon
- Type
- boolean
isInsideFootprint(point, id) → {boolean}
Determines if a point {x:,y:} is inside the footprint or one of the footprints for a given POI id.
Parameters:
Name | Type | Description |
---|---|---|
point |
point | |
id |
string | the place id. e.g. "L250" |
- Since:
- 1.8.3
Returns:
true if point is inside a footprint
- Type
- boolean
load(parametersopt) → {Promise}
This method is called to load and parse map data.
After calling this method, the mapviewer instance won't be ready to run yet, setup API needs to be called to complete the initialization.
See initialize for more information about the parameters.
Triggers loadCompleted if it succeeds, loadFailed otherwise.
Listening to loadCompleted or using the .then() callback, developers can add some tasks requiring map data, before starting to render the map. It can prove useful to use map data (for instance the routing network) without actually displaying the map.
After calling this method, the mapviewer instance won't be ready to run yet, setup API needs to be called to complete the initialization.
See initialize for more information about the parameters.
Triggers loadCompleted if it succeeds, loadFailed otherwise.
Listening to loadCompleted or using the .then() callback, developers can add some tasks requiring map data, before starting to render the map. It can prove useful to use map data (for instance the routing network) without actually displaying the map.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
parameters |
Object |
<optional> |
- Since:
- 1.9.7
- See:
-
- visioweb.Mapviewer#initialize
- visioweb.Mapviewer#setup
Returns:
where then(fulfilled(), rejected()) callbacks can be added.
- Type
- Promise
off(type, handleropt) → {boolean}
similar to jQuery off, used to remove event listeners
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | of event ex: 'routeComputed' or list of events separated by spaces 'exploreStateChanged exploreStateWillChange' | |
handler |
function |
<optional> |
handler to remove, if no handler, it will remove all events for that type. |
- Since:
- 1.7.14
- See:
Returns:
true if it removed any handler.
- Type
- boolean
offsetPosition(pPoint, pHeadingInDegrees, pPitchInDegrees, pDistanceInMeters) → {localPoint}
Offsets a position with a distance in meters given a direction.
Parameters:
Name | Type | Description |
---|---|---|
pPoint |
localPoint | The local point to start from, { x:, y:, z:} |
pHeadingInDegrees |
number | heading in degrees, 0 is North |
pPitchInDegrees |
number | pitch in degrees, 0 is horizontal, -90 is downward |
pDistanceInMeters |
number | distance in meters to move the point |
- Since:
- 1.7.16
- See:
Returns:
the start point moved pDistanceMeters in a given heading and pitch
- Type
- localPoint
on(type, handler)
similar to jQuery on, used to add event listeners.
You can listen to the mapviewer defined events, or you can listen to your own (for which you will have to trigger them).
Events triggered by VisioWeb:
- lifecycle: 'loadCompleted', 'loadFailed', 'initializeCompleted', 'initializedFailed'
- render: 'redraw', 'resize'
- interactivity: 'mouseup', 'routeComputed', 'exploreStateChanged', 'exploreStateWillChange'
If the handler returns false, other subsequent handlers will not be called.
Events triggered by VisioWeb:
- lifecycle: 'loadCompleted', 'loadFailed', 'initializeCompleted', 'initializedFailed'
- render: 'redraw', 'resize'
- interactivity: 'mouseup', 'routeComputed', 'exploreStateChanged', 'exploreStateWillChange'
If the handler returns false, other subsequent handlers will not be called.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | of event ex: 'routeComputed' or list of events separated by spaces, e.g. 'exploreStateChanged exploreStateWillChange' |
handler |
function | event object will contain .type, .args is an object |
- Since:
- 1.7.19 added 'redraw'
- See:
Examples
mapviewer.on('exploreStateWillChange',function(ev) {
// update UI
console.log('exploreStateWillChange');
// returning false would stop the floor from changing
});
mapviewer.on('exploreStateChanged',function(ev) {
// update UI
console.log('exploreStateChanged from floor ' + ev.args.previous.floorID + ' to floor' + ev.args.current.floorID);
});
// You need to add this in order for the resize trigger to work.
window.addEventListener('resize', function(event) {
var container = document.querySelector('#container');
mapviewer.resize(Utils.getElementWidth(container), Utils.getElementHeight(container));
});
mapviewer.on('resize', function(ev) {
console.log('new map dimension: '+ev.args.mapWidth+ 'x'+ev.args.mapHeight);
});
once(type, handler)
similar to jQuery once, used to add event listeners that will only be executed once, and automatically removed after execution.
If the handler returns false, other subsequent handlers will not be called.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | of event ex: 'routeComputed' or list of events separated by spaces, e.g. 'exploreStateChanged exploreStateWillChange'. |
handler |
function | event object will contain .type a string, .args is an object |
- Since:
- 1.7.22
- See:
Example
mapviewer.once('initializeCompleted',function(ev) {
// update UI
console.log('initializeCompleted');
// by using once, this function will be removed after first execution.
});
// setup some event that will cause a redraw, and wait for redraw
mapviewer.once('redraw',function(ev) {
// update UI
console.log('redraw just happened');
});
queryNearPlaces(position, parametersopt) → {Array}
finds all the places that are near a position within a certain threshold.
uses the position.alt or position.floor to figure out what layer to search on
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
position |
position | point | {"lat": lat, "lon": lon, "alt": z} or point {"x": x, "y": y, "floor": floorname}. If using .floor, it will only search in a particular floor. If using .alt, it will search on all layers that are at that altitude. If no .alt or .floor, it will use .alt=0 | ||||||||||||||||
parameters |
Object |
<optional> |
Properties
|
- Since:
- 1.7.18
Returns:
of {.id: placeid, .angle: heading angle between inputParameter.heading/position and the place, .distance: in meters}, sorted by distance.
- Type
- Array
Examples
//var positionAlt0 = {lon: 4.8835509, lat: 45.7399682, alt: 0.0};
//var positionFloor = {lon: 4.8835509, lat: 45.7399682, floor: "B2-UL02"};
var parameters = { heading: mapviewer.camera.heading, threshold: 10};
var position = mapviewer.camera.position; // this will set .x and .y
position.floor = mapviewer.getCurrentFloor()
var nearPlaces = mapviewer.queryNearPlaces(position, parameters);
if (nearPlaces.length > 0)
{
var nearPlace = nearPlaces[0];
console.log('the closest place is '+nearPlace.id + ' at distance '+nearPlace.distance + ' angle: '+nearPlace.angle);
}
// find places near start of instruction, assuming current instruction is in var instruction
// suppose you wanted to compute the heading between two lat/lon positions
function computeHeading(startPosition,endPosition) {
var startPoint = mapviewer.convertLatLonToPoint(startPosition);
var endPoint = mapviewer.convertLatLonToPoint(endPosition);
northPoint = mapviewer.offsetPosition(startPoint,0,0,10);
return mapviewer.computeHeadingAngle(startPoint,northPoint,endPoint);
}
var position = instruction.position; // this will set .lat and .lon
position.floor = instruction.dataset;
var parameters = {heading: computeHeading(instruction.positions[0], instruction.positions[1]), threshold: 20};
var nearPlaces = mapviewer.queryNearPlaces(position, parameters);
for (var i in nearPlaces)
{
var nearPlace = nearPlaces[i];
console.log('the closest place is '+nearPlace.id + ' at distance '+nearPlace.distance + ' angle: '+nearPlace.angle);
}
requestRedraw()
request the map to be redrawn and will trigger the calling of the postRenderListener's
- Since:
- 1.7.19
- See:
-
- visioweb.Mapviewer#addPostRenderListener
resetPlaceColor(place(s)) → {boolean}
Restores the original color for a placeObject, thus removing a potential highlight or temporary color.
Parameters:
Name | Type | Description |
---|---|---|
place(s) |
visioweb.Place | Array.<visioweb.Place> | string | Array.<string> | returned by getPlace() or place id(s) |
- Since:
- 1.8.3 replaces removeHighlight()
Returns:
Returns true if the original color was successfully restored.
- Type
- boolean
Example
mapviewer.resetPlaceColor(mapviewer.getPlace('161'))
resize(width, height)
Resize map. The container should have been resized beforehand.
If percentage size is used, then it is the integrator's responsibility to call the resize() function at every resize.
Note when resizing the amount of visible map will not change (assuming no change in aspect ratio).
The mapviewer.camera.maxRadius will not change either.
If percentage size is used, then it is the integrator's responsibility to call the resize() function at every resize.
Note when resizing the amount of visible map will not change (assuming no change in aspect ratio).
The mapviewer.camera.maxRadius will not change either.
Parameters:
Name | Type | Description |
---|---|---|
width |
number | The maps width |
height |
number | The maps height |
- Since:
- 1.7.19 resize trigger notification is sticky.
Example
window.addEventListener('resize', function(event) {
var container = document.querySelector('#container');
mapviewer.resize(Utils.getElementWidth(container), Utils.getElementHeight(container));
});
mapviewer.on('resize', function(ev) {
console.log('new map dimension: '+ev.args.mapWidth+ 'x'+ev.args.mapHeight);
});
setAutoUpdateLOD(value)
Auto update LOD will change the LOD of the current Floor as a function of the
camera distance. If you are enabling LODs by hand, it is best to disable
auto update LODs.
Default true
Default true
Parameters:
Name | Type | Description |
---|---|---|
value |
boolean | false to turn off auto updating all floors LODs. Default is true. |
- Since:
- 1.7.17 The autoUpdateLOD can be configured per floor.
setLanguage() → {boolean}
Change locale for venue.
Parameters:
Name | Type | Description |
---|---|---|
language. |
String |
- Since:
- 1.15.0
Returns:
true if language is found.
- Type
- boolean
setLogStatistic(enabled)
set Log Statistics flag.
Parameters:
Name | Type | Description |
---|---|---|
enabled |
boolean |
setLogStatisticAppID(appID)
set Log Statistics appID.
Parameters:
Name | Type | Description |
---|---|---|
appID |
string |
setLogStatisticURL(url)
set Log Statistics url.
Parameters:
Name | Type | Description |
---|---|---|
url |
string |
setPlaceColor(place, color) → {boolean}
Set a place color (as highlight, or temporarily).
Parameters:
Name | Type | Description |
---|---|---|
place |
visioweb.Place | string | placeObject returned by getPlace() or place id |
color |
color | in hexadecimal, e.g. 0x00ff00, or CSS-style string '#00ff00'. results are non predictable (usually black) if a non-hexadecimal value is given. |
- Since:
- 1.9.7 If called before loadCompleted or initializeCompleted, the options will be stored as pending and the actual call will happen when the initialization is complete.
Returns:
Returns true if a place was successfully highlighted.
- Type
- boolean
Example
mapviewer.setPlaceColor(mapviewer.getPlace('161'),0x00FF00)
setPlaceIcon(id, urlOrOptions)
Set a place icon.
The icon will have a fixed orientation except when the camera "switches" sides, at which point the icon will be flipped (the orientation changes 180 degrees).
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The place id e.g. "L250" |
urlOrOptions |
string | object | url The icon URL. The icon URL must be in the same domain as the viewer or if it is an object, it is expected to be like the parameters to addPoi including a 'url' attribute, and not including an 'id' attribute |
- Since:
- 1.9.7 If called before loadCompleted or initializeCompleted, the options will be stored as pending and the actual call will happen when the initialization is complete.
- See:
Example
// simple case
mapviewer.setPlaceIcon('LCARREFOUR', '../icons/Carrefour.png');
// if you only want the placename to be visible when close (because not so important
// or for performance reasons (this will make less text visible on the screen)
mapviewer.setPlaceIcon('L250', { url: '../icons/Zara.png',
visibilityRampStartInvisible: 800,
visibilityRampFullyInvisible: 1000 });
setPlaceName(id, labelOrOptions)
Set a place name by updating all of its labels.
All labels (text) will be updated.
If an icon shares the same ID and label is not empty it will be ignored.
The label will have a fixed orientation except when the camera "switches" sides, at which point the label is flipped (the orientation changes 180 degrees).
NOTE: on IE10 this function is very expensive. Avoid rendering all the labels.
NOTE: on IE10 this function is very expensive. Avoid rendering all the labels.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The place id e.g. "L250". |
labelOrOptions |
string | object | The place name to be displayed or if it is an object, it is expected to be like the parameters to addPoi including a 'text' attribute, and not including an 'id' attribute |
- Since:
- 1.9.7 If called before loadCompleted or initializeCompleted, the options will be stored as pending and the actual call will happen when the initialization is complete.
- See:
Example
// simple case
mapviewer.setPlaceName('LCARREFOUR', 'Carrefour');
// if you only want the placename to be visible when close (because not so important
// or for performance reasons (this will make less text visible on the screen)
mapviewer.setPlaceName('L250', { text: 'Zara',
// textTextureHeight: 20, // useful for low memory devices.
visibilityRampStartInvisible: 400,
visibilityRampFullyInvisible: 500
});
setSkybox(options)
allows developer to initialize a skybox using either a single strip image
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Example
mapviewer.setSkybox({
type: 'strip',
data: {
image: '../media/textures/skybox.island.png',
rhs: true
}
});
setTrackingEnabled(target, id, value)
set position tracking on a POI.
Parameters:
Name | Type | Description |
---|---|---|
target |
string | currently supported targets: 'camera' or 'poi' |
id |
string | only needed for poi target |
value |
string |
setupMultiBuildingView(parameters, multifloorConfig, stackGap) → {boolean}
Setup listeners and UI/UX for MultiBuilding management.
Instantiates visioweb.MultiBuildingView and visioweb.CameraDrivenExplorer
and exposes them through Mapviewer's multiBuildingView and cameraDrivenExplorer properties.
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parameters |
Object |
Properties
|
||||||||||||||||||
multifloorConfig |
Object |
Properties
|
||||||||||||||||||
stackGap |
number | overrides the stack gap value provided for each floor |
Returns:
true mapviewer.getExtraData() has correct multi building data (venue_layout)
- Type
- boolean
setupNavigationTranslator(places) → {boolean}
Instantiates visioweb.NavigationTranslator and exposes it through Mapviewer's navigationTranslator property.
Parameters:
Name | Type | Description |
---|---|---|
places |
Object | map of place names. |
Returns:
true navigationTranslator is properly initialized.
- Type
- boolean
setupView(mapDiv) → {Promise}
This method can be called before or after load.
It configures several organs of the viewer like the camera, the renderer and the event handlers.
It configures several organs of the viewer like the camera, the renderer and the event handlers.
Parameters:
Name | Type | Description |
---|---|---|
mapDiv |
DOM | The DOM element where the Mapviewer will render itself. It is used to obtain the size of the map. To avoid being able to see bubbles when they are outside the maps, its CSS should have 'overflow': 'hidden' |
- Since:
- 1.9.7
- See:
Returns:
where then(fulfilled(), rejected()) callbacks can be added.
- Type
- Promise
show()
Method to show the mapviewer's container.
It also calls mapviewer.start() to restart rendering.
start()
This method must be called when the HTML document is loaded in order to start the rendering.
Should be called as late as possible to minimize unnecessary screen refreshes.
stop()
This method must be called when the application wishes to stop rendering, for instance when unloading a map.
trigger(type, args, stickyopt)
trigger an event type. It will execute all triggers ordered by type, stopping if any handler returns exactly false
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
string | of event ex: 'routeComputed' or list of events separated by spaces 'exploreStateWillChange exploreStateChanged' | ||
args |
anything | as a function of event type | ||
sticky |
boolean |
<optional> |
false | if true, the system will keep the notification internally, any event type registration with .on after the trigger will get notified. It will only keep one sticky notification per type. |
- Since:
- 1.7.19 added sticky flag to keep notification, any subsequent .on will get notified, downside, the args get retained.
- See:
Returns:
false if any handler returned false
unload() → {Promise}
This method unloads all map data and resources.
- Since:
- 1.9.7
Returns:
resolves when map was properly unloaded.
- Type
- Promise