forked from Esri/arcgis-js-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraphic.js
5 lines (5 loc) · 3.81 KB
/
Graphic.js
1
2
3
4
5
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.20/esri/copyright.txt for details.
*/
define(["./chunks/_rollupPluginBabelHelpers","./chunks/tslib.es6","./geometry","./PopupTemplate","./symbols","./core/JSONSupport","./core/lang","./core/maybe","./core/uid","./core/accessorSupport/decorators/property","./core/accessorSupport/ensureType","./core/has","./core/Logger","./core/accessorSupport/decorators/subclass","./geometry/support/jsonUtils"],(function(e,t,r,o,s,i,p,u,a,l,n,y,c,h,m){"use strict";var b;let g=b=function(t){function r(...r){var o;return(o=t.call(this,...r)||this).isAggregate=!1,o.layer=null,o.popupTemplate=null,o.sourceLayer=null,Object.defineProperty(e._assertThisInitialized(o),"uid",{value:a.generateUID(),configurable:!0}),o}e._inheritsLoose(r,t);var o=r.prototype;return o.normalizeCtorArgs=function(e,t,r,o){return e&&!e.declaredClass?e:{geometry:e,symbol:t,attributes:r,popupTemplate:o}},o.getEffectivePopupTemplate=function(e=!1){if(this.popupTemplate)return this.popupTemplate;for(const t of[this.sourceLayer,this.layer])if(t){if("popupTemplate"in t&&t.popupTemplate)return t.popupTemplate;if(e&&"defaultPopupTemplate"in t&&u.isSome(t.defaultPopupTemplate))return t.defaultPopupTemplate}return null},o.getAttribute=function(e){return this.attributes&&this.attributes[e]},o.setAttribute=function(e,t){if(this.attributes){const r=this.getAttribute(e);this.attributes[e]=t,this._notifyLayer("attributes",r,t,e)}else this.attributes={[e]:t},this._notifyLayer("attributes",void 0,t,e)},o.getObjectId=function(){return this.sourceLayer&&"objectIdField"in this.sourceLayer&&this.sourceLayer.objectIdField?this.getAttribute(this.sourceLayer.objectIdField):null},o.toJSON=function(){return{geometry:u.isSome(this.geometry)?this.geometry.toJSON():null,symbol:u.isSome(this.symbol)?this.symbol.toJSON():null,attributes:{...this.attributes},popupTemplate:this.popupTemplate&&this.popupTemplate.toJSON()}},o.clone=function(){return new b(this.cloneProperties())},o.notifyGeometryChanged=function(){this._notifyLayer("geometry",this.geometry,this.geometry)},o.cloneProperties=function(){return{attributes:p.clone(this.attributes),geometry:p.clone(this.geometry),layer:this.layer,popupTemplate:this.popupTemplate&&this.popupTemplate.clone(),sourceLayer:this.sourceLayer,symbol:p.clone(this.symbol),visible:this.visible}},o._notifyLayer=function(e,t,r,o){if(!this.layer||!("graphicChanged"in this.layer))return;const s={graphic:this,property:e,oldValue:t,newValue:r};"attributes"===e&&(s.attributeName=o),this.layer.graphicChanged(s)},e._createClass(r,[{key:"attributes",set:function(e){const t=this._get("attributes");t!==e&&(this._set("attributes",e),this._notifyLayer("attributes",t,e))}},{key:"geometry",set:function(e){const t=this._get("geometry");t!==e&&(this._set("geometry",e),this._notifyLayer("geometry",t,e))}},{key:"symbol",set:function(e){const t=this._get("symbol");t!==e&&(this._set("symbol",e),this._notifyLayer("symbol",t,e))}},{key:"visible",set:function(e){const t=this._get("visible");t!==e&&(this._set("visible",e),this._notifyLayer("visible",t,e))}}]),r}(i.JSONSupport);return t.__decorate([l.property({value:null})],g.prototype,"attributes",null),t.__decorate([l.property({value:null,types:r.geometryTypes,json:{read:m.fromJSON}})],g.prototype,"geometry",null),t.__decorate([l.property({type:Boolean})],g.prototype,"isAggregate",void 0),t.__decorate([l.property()],g.prototype,"layer",void 0),t.__decorate([l.property({type:o})],g.prototype,"popupTemplate",void 0),t.__decorate([l.property()],g.prototype,"sourceLayer",void 0),t.__decorate([l.property({value:null,types:s.symbolTypes})],g.prototype,"symbol",null),t.__decorate([l.property({type:Boolean,value:!0})],g.prototype,"visible",null),g=b=t.__decorate([h.subclass("esri.Graphic")],g),function(e){e.generateUID=a.generateUID}(g||(g={})),g}));