GeoView.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 =
  46. /** @class */
  47. function (_super) {
  48. __extends(GeoView, _super);
  49. function GeoView() {
  50. var _this = _super !== null && _super.apply(this, arguments) || this;
  51. _this.type = GeoView.type;
  52. _this.focusBlurEnabled = true;
  53. return _this;
  54. }
  55. GeoView.prototype.init = function (ecModel, api) {
  56. this._api = api;
  57. };
  58. GeoView.prototype.render = function (geoModel, ecModel, api, payload) {
  59. this._model = geoModel;
  60. if (!geoModel.get('show')) {
  61. this._mapDraw && this._mapDraw.remove();
  62. this._mapDraw = null;
  63. return;
  64. }
  65. if (!this._mapDraw) {
  66. this._mapDraw = new MapDraw(api);
  67. }
  68. var mapDraw = this._mapDraw;
  69. mapDraw.draw(geoModel, ecModel, api, this, payload);
  70. mapDraw.group.on('click', this._handleRegionClick, this);
  71. mapDraw.group.silent = geoModel.get('silent');
  72. this.group.add(mapDraw.group);
  73. this.updateSelectStatus(geoModel, ecModel, api);
  74. };
  75. GeoView.prototype._handleRegionClick = function (e) {
  76. var eventData;
  77. findEventDispatcher(e.target, function (current) {
  78. return (eventData = getECData(current).eventData) != null;
  79. }, true);
  80. if (eventData) {
  81. this._api.dispatchAction({
  82. type: 'geoToggleSelect',
  83. geoId: this._model.id,
  84. name: eventData.name
  85. });
  86. }
  87. };
  88. GeoView.prototype.updateSelectStatus = function (model, ecModel, api) {
  89. var _this = this;
  90. this._mapDraw.group.traverse(function (node) {
  91. var eventData = getECData(node).eventData;
  92. if (eventData) {
  93. _this._model.isSelected(eventData.name) ? api.enterSelect(node) : api.leaveSelect(node); // No need to traverse children.
  94. return true;
  95. }
  96. });
  97. };
  98. GeoView.prototype.findHighDownDispatchers = function (name) {
  99. return this._mapDraw && this._mapDraw.findHighDownDispatchers(name, this._model);
  100. };
  101. GeoView.prototype.dispose = function () {
  102. this._mapDraw && this._mapDraw.remove();
  103. };
  104. GeoView.type = 'geo';
  105. return GeoView;
  106. }(ComponentView);
  107. export default GeoView;