As I understand I need to create custom widget that re-use TB map widget. Then somehow catch up zoom event and finally make Device type Query based on geo-coordinates.
self.onInit = function() {
let attributeService = self.ctx.$scope.$injector.get(self.ctx.servicesMap.get('attributeService'));
self.ctx.map = new TbMapWidgetV2('openstreet-map', false, self.ctx);
self.ctx.map.map.map.on('zoomend', function() {
updateMapBoudaries(self.ctx.map.map.map.getBounds(), 'SiloMap_');
self.ctx.map.map.map.on('dragend', function() {
updateMapBoudaries(self.ctx.map.map.map.getBounds(), 'SiloMap_');
function updateMapBoudaries(bounds, attributePrefix) {
let prefix = attributePrefix || '';
var geoAttributes = [
{ key: prefix + 'SouthWestLatitude', value: bounds.getSouthWest().lat },
{ key: prefix + 'SouthWestLongitude', value: bounds.getSouthWest().lng },
{ key: prefix + 'NorthEastLatitude', value: bounds.getNorthEast().lat },
{ key: prefix + 'NorthEastLongitude', value: bounds.getNorthEast().lng },
attributeService.saveEntityAttributes(
{'entityType': 'USER', 'id': self.ctx.currentUser.userId},
'SERVER_SCOPE',
geoAttributes
).subscribe(
ok => {
console.log('SUCCESS');
error =>{
console.log('Error: ', error);
Go to the dashboard and create new filter to check if Map widget window contains device bases on its longitude and latitude attribute values. The algorithm I took from Leaflet.js library
return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&
(sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);
sw, ne - boundary points of Map widget window, sw2.lng / ne2.lng - device longitude, sw2.lat/ ne2.lat- device latitude