Plugins
This document provides comprehensive documentation for two visualization libraries: echelonic.planner.js for 2D floor plan editing and echelonic.map.js for 3D WebGL-based map visualization.
Table of Contents
echelonic.map.js
echelonic.map.js is a high-performance, WebGL-based visualization tool for displaying 3D-extruded geofences, real-time tag locations, and heatmaps. It is designed to be highly configurable and interactive, with support for panning, zooming, rotation, and tilting via mouse, touch, and keyboard.
Quick Start
To get started, include the script in your project, create a container element in your HTML, and instantiate the map. Then, use the addLayer method to add a floor plan image.
HTML
<script src="echelonic.map.js"></script>
<link rel="stylesheet" href="echelonic.map.css"></link>
<div id="map-container" style="width: 100%; height: 600px;"></div>
JavaScript
// 1. Initialize the map
const map = new echelonicMap({
// Required
parentContainer: '#map-container',
baseUrl: 'https://api.echelonic.cc/:site_id',
authToken: 'YOUR_API_KEY',
// Common options
theme: '#0071e3',
stats: true,
heatmap: true,
trailsEnabled: true
});
// 2. Add a floor plan layer and fit it to the geofences
map.addLayer('floorplan-1', 'path/to/your/floorplan.png')
.fitToGeofences({ padding: 1.1, align: 'center' });
Configuration (Options)
The map can be configured by passing an options object to the constructor. Below are the available options, their default values, and descriptions.
Core Configuration
| Option | Type | Default | Description |
|---|---|---|---|
parentContainer |
String | Element |
document.body |
The DOM element or selector string for the container where the map will be rendered. |
authToken |
String |
null |
Required. Your API key for fetching map data. DO NOT hardcode API keys in front-end |
baseUrl |
String |
null |
Required. The base URL of the Echelonic API. |
updateInterval |
Number |
2000 |
The interval in milliseconds for fetching tag updates. The minimum value is 2000. |
autoCenter |
Boolean |
true |
If true, the map will gently pan to keep the center of the geofences in view if they drift too far off-screen. |
panAnimationMs |
Number |
200 |
The duration in milliseconds for the auto-center panning animation. |
Appearance & UI
| Option | Type | Default | Description |
|---|---|---|---|
theme |
String |
'#0071e3' |
The primary color theme for the map (geofence strokes, stats header, etc.), provided as a hex string. |
stats |
Boolean |
true |
If true, displays the statistics panel with online counts. |
geofences |
Boolean |
true |
If true, fetches and displays geofence polygons. |
heatmap |
Boolean |
true |
If true, displays a heatmap of tag locations. |
tagMarkers |
Boolean |
true |
If true, displays a circular marker for each individual tag. |
logo |
Boolean |
true |
If true, displays the Echelonic logo in the bottom corner. |
totalText |
String |
'Currently online' |
The label text displayed above the total online count in the stats panel. |
Initial View State
| Option | Type | Default | Description |
|---|---|---|---|
rotation |
Number |
0.78 |
The initial rotation of the map in radians. 0 is north-up. |
tilt |
Number |
0.17 |
The initial tilt of the map in radians (default is ~10°). 0 is a top-down view. |
zoom |
Number |
1 |
The initial zoom level of the map. |
Controls & Interaction Toggles
| Option | Type | Default | Description |
|---|---|---|---|
enableZoom |
Boolean |
true |
Enables zooming with the mouse wheel, touch gestures, and UI buttons. |
enableRotate |
Boolean |
true |
Enables rotating the map via mouse drag, touch gestures, and keyboard controls. |
enableTilt |
Boolean |
true |
Enables tilting the map via mouse drag, touch gestures, and keyboard controls. |
enableTopDown |
Boolean |
true |
Enables the "Reset View" button which fits geofences to the view and resets rotation/tilt. |
stabilizeOnRotate |
Boolean |
true |
When rotating or tilting, this feature automatically adjusts pan and zoom to keep the center of the view stable, preventing the map from flying off-screen. |
tiltTouchSensitivity |
Number |
0.01 |
Sensitivity for the two-finger vertical drag gesture to tilt the map. Higher values mean faster tilting. |
3D Perspective & Tilt
| Option | Type | Default | Description |
|---|---|---|---|
perspective |
Boolean |
true |
If true, enables pinhole perspective projection for a true 3D effect. If false, uses an affine (orthographic-style) projection. |
maxTilt |
Number |
Math.PI / 3 |
The maximum allowed tilt angle in radians (default is 60°). |
tiltStep |
Number |
Math.PI / 18 |
The amount of tilt in radians to apply per key press (default is 10°). |
fovDeg |
Number |
20 |
The camera's vertical field of view in degrees. Only applies when perspective is true. |
minFovDeg |
Number |
5 |
The minimum allowed field of view in degrees. |
maxFovDeg |
Number |
100 |
The maximum allowed field of view in degrees. |
autoFov |
Boolean |
true |
If true, automatically adjusts fovDeg based on the current tilt to keep geofences from distorting excessively. |
autoFovTargetRatio |
Number |
1.1 |
The maximum allowed scale difference between the nearest and farthest points of the geofence bounds before autoFOV adjusts. A larger value allows more distortion. |
autoFovSmoothing |
Number |
0.1 |
A value from 0 to 1 that controls how smoothly the FOV changes. 1 is instant, lower values are smoother. |
Geofence Extrusion (3D)
| Option | Type | Default | Description |
|---|---|---|---|
extrudeHeight |
Number |
3 |
The default height in world units to extrude geofence polygons, creating a 3D effect. |
geofenceHeights |
Object |
null |
An object mapping geofence names to specific extrusion heights. Example: { 'Room A': 4, 'Hallway': 2.8 }. These values override extrudeHeight. |
roofOpacity |
Number |
0.0 |
The opacity of the top face ("roof") of the extruded geofences, from 0.0 to 1.0. |
Tag Marker Customization
| Option | Type | Default | Description |
|---|---|---|---|
markerRadius |
Number |
10 |
The radius of the tag marker in pixels. |
markerFillColor |
String |
'#ffffff' |
The inner fill color of the tag markers, provided as a hex string. |
markerBorderThickness |
Number |
0.3 |
The thickness of the marker's border as a fraction of its radius (0.0 to 1.0). The border color is determined by the tag's movement state. |
Tag Trails
| Option | Type | Default | Description |
|---|---|---|---|
trailsEnabled |
Boolean |
true |
If true, draws a fading trail behind each moving tag. |
trailLength |
Number |
50 |
The number of historical points to store and render for each tag's trail. |
trailColor |
String |
null |
The color of the trail as a hex string. If null, it defaults to a color that contrasts with the main theme. |
Heatmap Configuration
| Option | Type | Default | Description |
|---|---|---|---|
heatRadiusPx |
Number |
25 |
The radius of each heatmap point in screen pixels. |
heatIntensity |
Number |
0.7 |
The base intensity (alpha) of each heatmap point before blending. |
heatOpacity |
Number |
0.8 |
The final opacity of the entire heatmap layer after rendering. |
heatBlur |
Number |
5.0 |
The blur radius in pixels applied to the heatmap for a smoother look. |
overlaySubdivisions |
Number |
32 |
The number of subdivisions for the map overlay grid. Higher values provide more accurate perspective warping at a small performance cost. |
Public Methods
You can interact with the map instance programmatically using these public methods.
Map Instance Methods
| Method | Description |
|---|---|
addLayer(name, url) |
Creates a new map overlay layer with the given name and image URL. Returns the new Layer instance, allowing for method chaining. |
showLayer(name) |
Makes the layer with the specified name the currently active and visible one. |
hideActiveLayer() |
Hides the currently active layer. |
setOptions(newOptions) |
Updates the map's configuration with a new options object. Any provided options will merge with the existing configuration. |
updateMapOverlay(config) |
Updates the active map layer with a new configuration object. This is useful for changing the overlay image or its properties dynamically. |
fitGeofencesInView() |
Adjusts the pan, zoom, and rotation to fit all loaded content (geofences and layers) within the viewport. Resets rotation to 0. |
fitOverlayToGeofences(options, layer) |
Resizes and repositions a map overlay to fit the bounds of the geofences. If layer is omitted, it operates on the active layer. The options object can contain padding (e.g., 1.1 for 10% padding) and align ('center', 'top-left', 'top-right', etc.). |
setRotation(angleRadians, anchorX, anchorY) |
Sets the map's rotation to a specific angle in radians. Optionally specify a screen coordinate anchor point. |
rotateBy(deltaRadians, anchorX, anchorY) |
Rotates the map by a given amount in radians. Optionally specify a screen coordinate anchor point. |
setTilt(angle) |
Sets the map's tilt to a specific angle in radians. The tilt is clamped between 0 and maxTilt. Pass null to reset to top-down view. |
setFov(deg) |
Sets the camera's field of view in degrees. |
setPerspectiveEnabled(enabled) |
Enables or disables the perspective projection mode. |
setRoofOpacity(opacity) |
Sets the opacity of the geofence roofs, from 0.0 to 1.0. |
zoomAt(x, y, factor) |
Zooms in or out by a given factor (e.g., 1.2 for zoom in, 0.9 for zoom out), anchored at the screen coordinates (x, y). |
analyzeTagData(tagData) |
A utility method that takes an array of raw tag data and returns a summary object: { online: Number, geofences: { [name]: count } }. |
renderData(jsonData) |
Manually updates the stats panel using data in the format returned by analyzeTagData. |
Layer Instance Methods
The addLayer() method returns a Layer instance, which has its own chainable methods for configuration.
map.addLayer('floor-1', 'url/to/image.png')
.setPosition(10, 20)
.setSize({ width: 200 })
.setOpacity(0.8)
.show();
| Method | Description |
|---|---|
setPosition(x, y) |
Sets the world position (top-left corner) of the layer. |
setSize({ width, height }) |
Sets the world size of the layer. If aspect lock is on, you only need to provide one dimension. |
setOpacity(opacity) |
Sets the layer's opacity from 0.0 to 1.0. |
fitToGeofences(options) |
A convenience method to fit this specific layer to the geofences. Same as the main map method but bound to this layer. |
show() |
Makes this layer the currently visible one. |
Controls and Interactions
The map supports a variety of interactions out of the box.
Mouse
- Pan: Left-click and drag.
- Rotate & Tilt: Right-click and drag. Alternatively, hold
CtrlorAltwhile left-clicking and dragging. - Zoom: Use the mouse wheel.
- Tooltip: Hover over a tag marker to see its ID.
Touch
- Pan: One-finger drag.
- Zoom: Two-finger pinch.
- Rotate: Two-finger twist.
- Tilt: Two-finger vertical drag.
Keyboard
- Rotate Left:
Qkey. - Rotate Right:
Ekey. - Tilt "Up" (increase angle):
Wkey. - Tilt "Down" (decrease angle):
Skey.
UI Buttons
Control buttons appear on the map for easy interaction.
- Zoom In / Out: Adjusts the map's zoom level.
- Reset View: Fits all geofences into view and resets rotation and tilt to
0. - View History: Opens a modal to select a date range. The map will then fetch and display a historical heatmap for that period, temporarily pausing real-time updates.
echelonic.planner.js
echelonic.planner.js is a feature-rich JavaScript library for creating interactive 2D floor plan editors. It allows users to place gateways, draw polygonal geofences, and measure distances. Also includes an RSSI-based fingerprinting toolkit for site surveys, a gateway signal heatmap, and a configurable measurement grid.
Quick Start
To get started, include the script in your project, create a container element in your HTML, and instantiate the planner with your required options.
Download echelonic.plannerHTML
<script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>
<script src="echelonic.planner.js"></script>
<link rel="stylesheet" href="echelonic.planner.css"></link>
<div id="planner-container" style="width: 100%; height: 700px;"></div>
JavaScript
// Basic initialization
const planner = new echelonicPlanner(
document.getElementById('planner-container'),
{
// Required
baseUrl: 'https://api.echelonic.cc/:site_id',
authToken: 'YOUR_AUTH_TOKEN',
map: 'path/to/your/floorplan.png',
mapScale: 50, // 50 pixels = 1 meter
// Common options
colorScheme: 'teal',
accentColor: 'orange',
darkMode: true,
// Required for fingerprinting
mqtt: {
brokerUrl: 'wss://your_mqtt_broker_url',
topic: 'your/topic',
tagId: 'YOUR_TAG_ID'
}
}
);
Configuration (Options)
The planner is configured by passing an options object as the second argument to the constructor.
Core & API Configuration
| Option | Type | Default | Description |
|---|---|---|---|
map |
String |
null |
Required. The URL to the floor plan image to be used as the background. |
mapScale |
Number |
0 |
Required. The scale of the map in pixels per meter. This must be a positive number. |
baseUrl |
String |
'https://api.echelonic.cc' |
The base URL for the API endpoints. |
authToken |
String |
null |
A bearer token to be included in the Authorization header of API requests. |
endpoints |
Object |
(see source) | An object containing the specific paths for API actions (list, create, update, delete for gateways, geofences, and fingerprints). |
Appearance & UI
| Option | Type | Default | Description |
|---|---|---|---|
colorScheme |
String |
'blue' |
The primary color scheme for UI elements like buttons and geofences. Accepts Material Design color names (e.g., 'red', 'teal', 'deepPurple'). |
accentColor |
String |
'deepOrange' |
The accent color, used for gateways and primary action buttons. |
darkMode |
Boolean |
false |
If true, applies a dark theme to the UI panels and controls. |
Fingerprinting (MQTT) Configuration
| Option | Type | Default | Description |
|---|---|---|---|
mqtt |
Object |
(see source) | An object containing MQTT connection details required for the fingerprinting feature. Must contain brokerUrl, topic, and tagId. |
Grid Configuration
Pass a grid object in the options to customize the background measurement grid.
| Property | Type | Default | Description |
|---|---|---|---|
enabled |
Boolean |
true |
Toggles the visibility of the grid. |
spacingMeters |
Number |
1 |
The distance in meters between each grid line. |
majorEvery |
Number |
5 |
Draws a thicker "major" line every N lines. |
showLabels |
Boolean |
false |
If true, shows meter labels on major grid lines. |
Public Methods
| Method | Description |
|---|---|
zoomIn() |
Zooms into the center of the canvas. |
zoomOut() |
Zooms out from the center of the canvas. |
zoomToFit() |
Adjusts the pan and zoom to fit the entire map image within the canvas viewport. |
redrawCanvas() |
Forces a complete redraw of the canvas. Useful after programmatic changes or container resizing. |
Controls and Interactions
- Pan: Click and drag on an empty area of the map.
- Zoom: Use the UI buttons, the mouse wheel, or a two-finger pinch gesture on touch devices.
- Add Gateway: Click the "Add Gateway" button, then click on the map to place it. A modal will appear to enter details.
- Add Geofence: Click the "Add Geofence" button. Click on the map to place vertices. To finish, click the first vertex again or click the "Confirm" button in the top-right controls. A modal will then appear for details.
- Select Item: Click on any gateway or geofence polygon/node to select it.
- Move Item: Click and drag a selected gateway or a selected geofence node to move it. If you move a gateway and fingerprint data exists, a warning modal will appear asking you to confirm, as this action invalidates the old data.
- Add Geofence Node: When a geofence is selected, small nodes will appear at the midpoint of each edge. Drag one of these to create a new vertex.
- Delete Item: Select an item (gateway, geofence, or geofence node) and click the corresponding "Remove" button that appears in the top-right controls.
- Measure Distance: Click the "Measure" button. Click a start point on the map, then move the mouse to see the live distance. Click a second time to finalize the measurement and exit the measurement mode.
- View Heatmap: Use the "Heatmap" dropdown to select an environment type (e.g., Office, Industrial). A heatmap visualizing the estimated signal strength from all placed gateways will be overlaid on the map.
- View Grid: A background grid representing meters can be displayed. It can be configured or disabled via the
gridoption during initialization. - Fingerprint Collection:
- Click the fingerprint icon to enter collection mode. A new panel will appear.
- The panel will connect to the configured MQTT broker and display live RSSI readings from gateways for the specified tag.
- Click anywhere on the map to select a location for a new fingerprint.
- Click the "Record" button. The planner will collect several RSSI readings and save a smoothed value (using an Exponential Moving Average) for that point.
- The recorded point will appear on the map. You can repeat this process for many locations.
- To delete a recorded point, simply click on it, then click the "Delete" button.
- Click "Update" to save all collected fingerprints to the server.
- Click "Download" to export the fingerprint data as a JSON file.
- Click "Close" or the main fingerprint button again to exit collection mode.