map-widget2_and_subscription_file_update

This commit is contained in:
Maksym Dudnik 2019-01-04 11:52:56 +02:00 committed by Andrew Shvayka
parent 0a950a4916
commit 49d623391e
2 changed files with 17 additions and 4 deletions

View File

@ -648,6 +648,12 @@ export default class Subscription {
}
dataUpdated(sourceData, datasourceIndex, dataKeyIndex, apply) {
for (var x = 0; x < this.datasourceListeners.length; x++) {
this.datasources[x].dataReceived = this.datasources[x].dataReceived === true;
if (this.datasourceListeners[x].datasourceIndex === datasourceIndex && sourceData.data.length > 0) {
this.datasources[x].dataReceived = true;
}
}
this.notifyDataLoaded();
var update = true;
var currentData;

View File

@ -60,7 +60,8 @@ export default class TbMapWidgetV2 {
var minZoomLevel = this.drawRoutes ? 18 : 15;
this.initBounds = true;
var initCallback = function() {
tbMap.update();
@ -89,6 +90,9 @@ export default class TbMapWidgetV2 {
} else if (mapProvider === 'tencent-map') {
this.map = new TbTencentMap($element,this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, minZoomLevel, settings.tmApiKey, settings.tmDefaultMapType);
}
tbMap.initBounds = true;
}
setCallbacks(callbacks) {
@ -444,6 +448,7 @@ export default class TbMapWidgetV2 {
}
function updateLocations(data, datasources) {
var locationsChanged = false;
var bounds = tbMap.map.createBounds();
var dataMap = toLabelValueMap(data, datasources);
@ -457,8 +462,11 @@ export default class TbMapWidgetV2 {
}
}
if (locationsChanged && tbMap.initBounds) {
tbMap.initBounds = !datasources.every(
function (ds) {
return ds.dataReceived === true;
});
tbMap.map.fitBounds(bounds);
tbMap.initBounds = false;
}
}
@ -480,7 +488,6 @@ export default class TbMapWidgetV2 {
content = fillPattern(settings.tooltipPattern, settings.tooltipReplaceInfo, data);
return fillPatternWithActions(content, 'onTooltipAction', tooltip.markerArgs);
}
if (this.map && this.map.inited() && this.subscription) {
if (this.subscription.data) {
if (!this.locations) {