英文:
Thingsboard draw line on map not a polygon
问题
我想知道如何在Thingsboard中使用自定义小部件绘制地图上的线条。是否有人尝试过在其中使用JavaScript进行修改?
在这里要怎么做:
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
};
}
这段代码应该放在哪里?
//这段代码应该放在哪里?
var lineCoordinates = [
{ lat: 37.774929, lng: -122.419418 }, // 起始点
{ lat: 37.804996, lng: -122.407547 } // 终点
];
英文:
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
];
答案1
得分: 0
很抱歉,使用默认的地图小部件作为自定义小部件的基础是不可能的。您必须从头开始完全创建自定义小部件。
但是,绘制线条也是可能的,而无需开发自己的小部件。这可以使用默认地图小部件直接实现:
属性:
[
[
5.04409280561122,
10.892496518385302
],
[
5.048902066863962,
10.899666269572215
],
[
5.0494364270244905,
10.900417590804363
]
]
在此处查找更多详细信息:
https://github.com/thingsboard/thingsboard/issues/6311
英文:
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:
Attribute:
[
[
5.04409280561122,
10.892496518385302
],
[
5.048902066863962,
10.899666269572215
],
[
5.0494364270244905,
10.900417590804363
]
]
Find more details here:
https://github.com/thingsboard/thingsboard/issues/6311
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论