Commit 49d623391ef9fb1b5a681dec35de9f3b9941b032

Authored by Maksym Dudnik
Committed by Andrew Shvayka
1 parent 0a950a49

map-widget2_and_subscription_file_update

... ... @@ -648,6 +648,12 @@ export default class Subscription {
648 648 }
649 649
650 650 dataUpdated(sourceData, datasourceIndex, dataKeyIndex, apply) {
  651 + for (var x = 0; x < this.datasourceListeners.length; x++) {
  652 + this.datasources[x].dataReceived = this.datasources[x].dataReceived === true;
  653 + if (this.datasourceListeners[x].datasourceIndex === datasourceIndex && sourceData.data.length > 0) {
  654 + this.datasources[x].dataReceived = true;
  655 + }
  656 + }
651 657 this.notifyDataLoaded();
652 658 var update = true;
653 659 var currentData;
... ...
... ... @@ -60,7 +60,8 @@ export default class TbMapWidgetV2 {
60 60
61 61 var minZoomLevel = this.drawRoutes ? 18 : 15;
62 62
63   - this.initBounds = true;
  63 +
  64 +
64 65
65 66 var initCallback = function() {
66 67 tbMap.update();
... ... @@ -89,6 +90,9 @@ export default class TbMapWidgetV2 {
89 90 } else if (mapProvider === 'tencent-map') {
90 91 this.map = new TbTencentMap($element,this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, minZoomLevel, settings.tmApiKey, settings.tmDefaultMapType);
91 92 }
  93 +
  94 +
  95 + tbMap.initBounds = true;
92 96 }
93 97
94 98 setCallbacks(callbacks) {
... ... @@ -444,6 +448,7 @@ export default class TbMapWidgetV2 {
444 448 }
445 449
446 450 function updateLocations(data, datasources) {
  451 +
447 452 var locationsChanged = false;
448 453 var bounds = tbMap.map.createBounds();
449 454 var dataMap = toLabelValueMap(data, datasources);
... ... @@ -457,8 +462,11 @@ export default class TbMapWidgetV2 {
457 462 }
458 463 }
459 464 if (locationsChanged && tbMap.initBounds) {
460   - tbMap.map.fitBounds(bounds);
461   - tbMap.initBounds = false;
  465 + tbMap.initBounds = !datasources.every(
  466 + function (ds) {
  467 + return ds.dataReceived === true;
  468 + });
  469 + tbMap.map.fitBounds(bounds);
462 470 }
463 471 }
464 472
... ... @@ -480,7 +488,6 @@ export default class TbMapWidgetV2 {
480 488 content = fillPattern(settings.tooltipPattern, settings.tooltipReplaceInfo, data);
481 489 return fillPatternWithActions(content, 'onTooltipAction', tooltip.markerArgs);
482 490 }
483   -
484 491 if (this.map && this.map.inited() && this.subscription) {
485 492 if (this.subscription.data) {
486 493 if (!this.locations) {
... ...