Toggle navigation
Wialon Playground
Add library
jQuery latest
Bootstrap 3.3.1
Wialon Javascript SDK
Run
Get code
Fork
Save
Examples
Login
Get units
Change unit icon
Get messages
Get sensors
Edit sensors
Commands
Monitoring notification
Track layer
Get resources
Resources and accounts
Account parameters
Do payment
Management Driver
Create notification
Get geofences
Geofence parameters
Create geofence
Gurtam map
Units on map
Unit trace
Create report template
Execute report
Execute custom report
Create driver
Bind driver to unit
Unit edit fields
Import fillings
Token login for site
Advanced authorization form
Token usage in app
Account hierarchy
Nearest units
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Wialon Playground - Get units</title> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script type="text/javascript" src="https://hst-api.wialon.com/wsdk/script/wialon.js"></script> </head> <body> <div id="log"></div> </body> </html>
HTML
#log { border: 1px solid #c6c6c6; } .icon {float:left; margin:10px;}
CSS
// Print message to log function msg(text) { $("#log").append(text + "<br/>"); } // execute when DOM ready $(document).ready(function () { var sess = wialon.core.Session.getInstance(); // get instance of current Session sess.initSession("https://hst-api.wialon.com"); // init session // CASE 1: call while session inactive (not logged in) sess.updateDataFlags( // load items to current session [{type: "type", data: "avl_unit", flags: 0x1, mode: 0}], // Items specification function (code) { // updateDataFlags callback if (code) { msg('CASE 1: "update_data_flags" before login error: ' + wialon.core.Errors.getErrorText(code)); } else { msg('CASE 1: "update_data_flags" before login success'); } } ); // For more info about how to generate token check // http://sdk.wialon.com/playground/demo/app_auth_token sess.loginToken("5dce19710a5e26ab8b7b8986cb3c49e58C291791B7F0A7AEB8AFBFCEED7DC03BC48FF5F8", "", // try to login function (code) { // login callback // if error code - print error message if (code){ msg(wialon.core.Errors.getErrorText(code)); return; } // CASE 2: call when session is active sess.updateDataFlags( // load items to current session [{type: "type", data: "avl_unit", flags: 0x1, mode: 0}], // Items specification function (code) { // updateDataFlags callback if (code) { msg('CASE 2: "update_data_flags" after login error: ' + wialon.core.Errors.getErrorText(code)); } else { msg('CASE 2: "update_data_flags" after login success'); } } ); }); });
JS
Result
Source code of example
Close ✕
×
Source code