cione-comp-lib
Version:
`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`
68 lines (67 loc) • 2.31 kB
JavaScript
import { __extends } from "../../../../tslib/tslib.es6.mjs";
import MapDraw from "../helper/MapDraw.mjs";
import ComponentView from "../../view/Component.mjs";
import { getECData } from "../../util/innerStore.mjs";
import { findEventDispatcher } from "../../util/event.mjs";
var GeoView = function(_super) {
__extends(GeoView2, _super);
function GeoView2() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = GeoView2.type;
_this.focusBlurEnabled = true;
return _this;
}
GeoView2.prototype.init = function(ecModel, api) {
this._api = api;
};
GeoView2.prototype.render = function(geoModel, ecModel, api, payload) {
this._model = geoModel;
if (!geoModel.get("show")) {
this._mapDraw && this._mapDraw.remove();
this._mapDraw = null;
return;
}
if (!this._mapDraw) {
this._mapDraw = new MapDraw(api);
}
var mapDraw = this._mapDraw;
mapDraw.draw(geoModel, ecModel, api, this, payload);
mapDraw.group.on("click", this._handleRegionClick, this);
mapDraw.group.silent = geoModel.get("silent");
this.group.add(mapDraw.group);
this.updateSelectStatus(geoModel, ecModel, api);
};
GeoView2.prototype._handleRegionClick = function(e) {
var eventData;
findEventDispatcher(e.target, function(current) {
return (eventData = getECData(current).eventData) != null;
}, true);
if (eventData) {
this._api.dispatchAction({
type: "geoToggleSelect",
geoId: this._model.id,
name: eventData.name
});
}
};
GeoView2.prototype.updateSelectStatus = function(model, ecModel, api) {
var _this = this;
this._mapDraw.group.traverse(function(node) {
var eventData = getECData(node).eventData;
if (eventData) {
_this._model.isSelected(eventData.name) ? api.enterSelect(node) : api.leaveSelect(node);
return true;
}
});
};
GeoView2.prototype.findHighDownDispatchers = function(name) {
return this._mapDraw && this._mapDraw.findHighDownDispatchers(name, this._model);
};
GeoView2.prototype.dispose = function() {
this._mapDraw && this._mapDraw.remove();
};
GeoView2.type = "geo";
return GeoView2;
}(ComponentView);
var GeoView$1 = GeoView;
export { GeoView$1 as default };