I am using the JavaScript SDK 3.18 and I am relatively new to the SDK. I am using Angular 2 and TypeScript and I am trying to create my own layer that extends the ArcGISDynamicMapServiceLayer and I need access to that map so I can listen to the extent-changed event. I have tried the following in my TypeScript.
export class MyDynamicMapServiceLayer extends ArcGISDynamicMapServiceLayer { constructor(url: string, options? ArcGISDynamicMapServiceLayerOptions) { super(url, options); this.on('load', (event) => { //Check this.getMap() here this.getMap(); this._map; this['_map'] event.target.getMap(); event.layer.getMap(); }); } }
I have tried to get a reference to the map from the load event several different ways without success. What is the correct way to either get a reference to the map or to listen to the extent changed (so I can get access to the current LOD) from within a custom layer? Any suggestions would be appreciated.
Thanks,
-eric
Gotcha. I re-read your original post and I've seen this behavior before. There has been much discussion in past on what exactly the 'load' event represents. From the API reference "Fires after layer properties for the layer are successfully populated," which is sort of ambiguous. My hunch concurs with yours that the layer has not finished loading "all" of its resources. Have you tried listening for the 'update-end' event just to see if it makes a difference?