Тема: session
good day, i have an app using wialon and i would like to know how i can make a search by name and no by id, example:
function init() {
var sess = wialon.core.Session.getInstance();
// specify what kind of data should be returned
var flags = wialon.item.Item.dataFlag.base | wialon.item.Unit.dataFlag.lastMessage;
sess.loadLibrary("itemIcon");
sess.updateDataFlags(
[{type: "type", data: "avl_unit", flags: flags,mode: 0}],
function (code) {
if (code) { msg(wialon.core.Errors.getErrorText(code)); return; }
var units = sess.getItems("avl_unit");
var unidad = wialon.core.Session.getInstance().getItem(13422969);
var posicion = unidad.getPosition();
if (map) {
var icon = L.icon({
iconUrl: unidad.getIconUrl(32)
});
if (!marker) {
marker = L.marker({lat: posicion.y, lng: posicion.x}, {icon: icon}).addTo(map);
} else {
marker.setLatLng({lat: posicion.y, lng: posicion.x});
marker.setIcon(icon);
}
map.setView({lat: posicion.y, lng: posicion.x});
}
alert(unidad.getName());
if (!units || !units.length){ msg("No units found"); return; }
});
}
next line, find car by id
var unidad = wialon.core.Session.getInstance().getItem(13422969);
i wanna use search by name
var unidad = wialon.core.Session.getInstance().getName(name-car);
is possible do this? thanks for your help