GeoView.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. /**
  20. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21. */
  22. /*
  23. * Licensed to the Apache Software Foundation (ASF) under one
  24. * or more contributor license agreements. See the NOTICE file
  25. * distributed with this work for additional information
  26. * regarding copyright ownership. The ASF licenses this file
  27. * to you under the Apache License, Version 2.0 (the
  28. * "License"); you may not use this file except in compliance
  29. * with the License. You may obtain a copy of the License at
  30. *
  31. * http://www.apache.org/licenses/LICENSE-2.0
  32. *
  33. * Unless required by applicable law or agreed to in writing,
  34. * software distributed under the License is distributed on an
  35. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36. * KIND, either express or implied. See the License for the
  37. * specific language governing permissions and limitations
  38. * under the License.
  39. */
  40. import { __extends } from "tslib";
  41. import MapDraw from '../helper/MapDraw.js';
  42. import ComponentView from '../../view/Component.js';
  43. import { getECData } from '../../util/innerStore.js';
  44. import { findEventDispatcher } from '../../util/event.js';
  45. var GeoView = /** @class */function (_super) {
  46. __extends(GeoView, _super);
  47. function GeoView() {
  48. var _this = _super !== null && _super.apply(this, arguments) || this;
  49. _this.type = GeoView.type;
  50. _this.focusBlurEnabled = true;
  51. return _this;
  52. }
  53. GeoView.prototype.init = function (ecModel, api) {
  54. this._api = api;
  55. };
  56. GeoView.prototype.render = function (geoModel, ecModel, api, payload) {
  57. this._model = geoModel;
  58. if (!geoModel.get('show')) {
  59. this._mapDraw && this._mapDraw.remove();
  60. this._mapDraw = null;
  61. return;
  62. }
  63. if (!this._mapDraw) {
  64. this._mapDraw = new MapDraw(api);
  65. }
  66. var mapDraw = this._mapDraw;
  67. mapDraw.draw(geoModel, ecModel, api, this, payload);
  68. mapDraw.group.on('click', this._handleRegionClick, this);
  69. mapDraw.group.silent = geoModel.get('silent');
  70. this.group.add(mapDraw.group);
  71. this.updateSelectStatus(geoModel, ecModel, api);
  72. };
  73. GeoView.prototype._handleRegionClick = function (e) {
  74. var eventData;
  75. findEventDispatcher(e.target, function (current) {
  76. return (eventData = getECData(current).eventData) != null;
  77. }, true);
  78. if (eventData) {
  79. this._api.dispatchAction({
  80. type: 'geoToggleSelect',
  81. geoId: this._model.id,
  82. name: eventData.name
  83. });
  84. }
  85. };
  86. GeoView.prototype.updateSelectStatus = function (model, ecModel, api) {
  87. var _this = this;
  88. this._mapDraw.group.traverse(function (node) {
  89. var eventData = getECData(node).eventData;
  90. if (eventData) {
  91. _this._model.isSelected(eventData.name) ? api.enterSelect(node) : api.leaveSelect(node);
  92. // No need to traverse children.
  93. return true;
  94. }
  95. });
  96. };
  97. GeoView.prototype.findHighDownDispatchers = function (name) {
  98. return this._mapDraw && this._mapDraw.findHighDownDispatchers(name, this._model);
  99. };
  100. GeoView.prototype.dispose = function () {
  101. this._mapDraw && this._mapDraw.remove();
  102. };
  103. GeoView.type = 'geo';
  104. return GeoView;
  105. }(ComponentView);
  106. export default GeoView;