1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Wialon Playground - Unit trace</title>
6
    <script type="text/javascript" src="//code.jquery.com/jquery-latest.min.js"></script>
7
    <script type="text/javascript" src="//hst-api.wialon.com/wsdk/script/wialon.js"></script>
8
</head>
9
<body>
10
11
<!-- load map -->
12
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.2/leaflet.css" />
13
<script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.2/leaflet.js"></script>
14
15
<div id="map"></div>
16
Select unit:<select id="units"><option></option></select>
17
<div id="log"></div>
18
19
</body>
20
</html>
HTML
2
 
1
#map{ width:500px; height:400px; }
2
#log{ border: 1px solid #c6c6c6; }
CSS
135
 
1
var map, marker, unitID, unitEventID, polyline, mapWaypts = []; // global variables
2
3
// Print message to log
4
function msg(text) { $("#log").prepend(text + "<br/>"); }
5
6
function init() { // Execute after login succeed
7
    var sess = wialon.core.Session.getInstance(); // get instance of current Session
8
    // specify what kind of data should be returned
9
    var flags = wialon.item.Item.dataFlag.base;
10
11
    sess.loadLibrary("itemIcon"); // load Icon Library 
12
    sess.updateDataFlags( // load items to current session
13
        [{type: "type", data: "avl_unit", flags: flags, mode: 0}], // items specification
14
        function (code) { // updateDataFlags callback
15
            if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code
16
            
17
            var units = sess.getItems("avl_unit"); // get loaded 'avl_resource's items
JS
Result
Source code of example Close ✕
1
 
1
/*source*/