MapWidgetProxy.js
2.55 KB
// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.6/esri/copyright.txt for details.
//>>built
define("require exports ../core/tsSupport/extendsHelper ../core/tsSupport/decorateHelper ../core/typescript ../geometry/SpatialReference ../geometry/support/jsonUtils ./core/messageHandler ./core/MessageReceiver ./GraphicsLayerProxy".split(" "),function(n,p,h,d,e,k,f,c,l,m){return function(g){function b(a){a=g.call(this)||this;a._listeningToMap=!1;a.id=null;a.name=null;a.spatialReference=null;return a}h(b,g);b.prototype._setConfig=function(a){this.inherited(arguments);this.spatialReference=new k(a.spatialReference)};
b.prototype._messageReceived=function(a){if(void 0!==a.args&&void 0!==a.args.mapWidgetId&&this.id===a.args.mapWidgetId)switch(a.functionName.toLowerCase()){case "extentchanged":return this._mapExtentChanged(a.args)}};b.prototype._mapExtentChanged=function(a){a=f.fromJSON(a.extent);this.mapExtentChanged(a);this.emit("map-extent-change",{extent:a})};b.prototype.subscribeToMapEvents=function(){this._listeningToMap||(this._listeningToMap=!0,c._sendMessage({functionName:"subscribeToMapEvents",args:{mapWidgetId:this.id}}))};
b.prototype.unsubscribeFromMapEvents=function(){this._listeningToMap&&(this._listeningToMap=!1,c._sendMessage({functionName:"unsubscribeFromMapEvents",args:{mapWidgetId:this.id}}))};b.prototype.mapExtentChanged=function(a){};b.prototype.getMapExtent=function(){return c._sendMessageWithReply({functionName:"getExtent",args:{mapWidgetId:this.id}}).then(function(a){return f.fromJSON(a.extent)})};b.prototype.setExtent=function(a){a&&a.type&&"extent"===a.type&&c._sendMessage({functionName:"setExtent",args:{mapWidgetId:this.id,
extent:a.toJSON()}})};b.prototype.panTo=function(a){a&&a.type&&"point"===a.type&&c._sendMessage({functionName:"panTo",proxyName:"MapWidgetProxy",args:{mapWidgetId:this.id,mapPoint:a.toJSON()}})};b.prototype.createGraphicsLayerProxy=function(a){var b=this,d={functionName:"createGraphicsLayer",args:{mapWidgetId:this.id,visible:a&&a.visible?a.visible:!0,opacity:a&&a.opacity?a.opacity:1,minScale:a&&a.minScale?a.minScale:0,maxScale:a&&a.maxScale?a.maxScale:0,renderer:a&&a.renderer?a.renderer.toJson():
void 0}};return c._sendMessageWithReply(d).then(function(c){return new m(b,c.graphicsLayerId,a)})};b.prototype.destroyGraphicsLayerProxy=function(a){a&&c._sendMessage({functionName:"removeGraphicsLayer",args:{mapWidgetId:this.id,graphicsLayerId:a._id}})};d([e.shared("esri.opsdashboard.MapWidgetProxy")],b.prototype,"declaredClass",void 0);return b=d([e.subclass()],b)}(l)});