Search code examples
thingsboard

Thingsboard draw line on map not a polygon


I want to know how to draw lines on the map using custom widget in Thingsboard. Is there anyone who tried to modified inside using javascript?

how to do it here


self.onInit = function() {
    self.ctx.map = new TbMapWidgetV2('openstreet-map', false, self.ctx);
     


}

self.onDataUpdated = function() {
        
    self.ctx.map.update();
    
}

self.onResize = function() {
    self.ctx.map.resize();
}

self.actionSources = function() {
    return TbMapWidgetV2.actionSources();
}

self.onDestroy = function() {
    self.ctx.map.destroy();
}

self.typeParameters = function() {
    return {
        hasDataPageLink: true
    };
}

Where should I put this?

//where should i put this?

var lineCoordinates = [
  { lat: 37.774929, lng: -122.419418 },  // Start point
  { lat: 37.804996, lng: -122.407547 }   // End point
];

Solution

  • Unfortunately, this is not possible with the default map widgets as the basis for a custom widget. You have to create the custom widget completely from scratch.

    But drawing of lines is also possible without having to develop your own widget. This works out-of-the-box with default map widgets:

    Widget Configuration: enter image description here

    enter image description here

    enter image description here

    Attribute:

    [
      [
        5.04409280561122,
        10.892496518385302
      ],
      [
        5.048902066863962,
        10.899666269572215
      ],
      [
        5.0494364270244905,
        10.900417590804363
      ]
    ]
    

    Find more details here: https://github.com/thingsboard/thingsboard/issues/6311