{"action":"created","issue":{"url":"https://api.github.com/repos/jwerts/jsapi4-angular2/issues/7","repository_url":"https://api.github.com/repos/jwerts/jsapi4-angular2","labels_url":"https://api.github.com/repos/jwerts/jsapi4-angular2/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/jwerts/jsapi4-angular2/issues/7/comments","events_url":"https://api.github.com/repos/jwerts/jsapi4-angular2/issues/7/events","html_url":"https://github.com/jwerts/jsapi4-angular2/issues/7","id":185665701,"number":7,"title":"Esri Maps","user":{"login":"benitazz","id":3354516,"avatar_url":"https://avatars.githubusercontent.com/u/3354516?v=3","gravatar_id":"","url":"https://api.github.com/users/benitazz","html_url":"https://github.com/benitazz","followers_url":"https://api.github.com/users/benitazz/followers","following_url":"https://api.github.com/users/benitazz/following{/other_user}","gists_url":"https://api.github.com/users/benitazz/gists{/gist_id}","starred_url":"https://api.github.com/users/benitazz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benitazz/subscriptions","organizations_url":"https://api.github.com/users/benitazz/orgs","repos_url":"https://api.github.com/users/benitazz/repos","events_url":"https://api.github.com/users/benitazz/events{/privacy}","received_events_url":"https://api.github.com/users/benitazz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-27T13:17:19Z","updated_at":"2016-10-27T14:41:52Z","closed_at":null,"body":"Hi,\r\n\r\nI have followed your example and used the same pattern on my project. The current problem that I have is that it seems like I cannot change the layers on the fly, what I mean is that I have added a method on the map service to change the tile layers according to the user selection: \r\n\r\nhere is my method to add tile layers:\r\n\r\npublic addTileMapLayer(layerData) {\r\n\r\n    let tileLayer = new TileLayer({\r\n      url: layerData.url,\r\n      title: layerData.name\r\n    });\r\n\r\n    this.map.layers.removeAll();\r\n\r\n    this.map.add(tileLayer);\r\n  }\r\n\r\nthe above method does not seem to work outside the map service, however if I call the same method in the map service constructor then all is well.\r\n\r\n I would like to be able to call the method when I consume the service on the other component and be able to change the map layers according to the user selection. Please assist\r\n\r\nhere is an example of calling the map service method from my layer component and the map does not get rendered with the new layer that I have selected :\r\n\r\n public  onClick(legendLayer) {\r\n        var map = this._mapService.map;\r\n        this._mapService.addTileMapLayer(legendLayer);\r\n    }"},"comment":{"url":"https://api.github.com/repos/jwerts/jsapi4-angular2/issues/comments/256661319","html_url":"https://github.com/jwerts/jsapi4-angular2/issues/7#issuecomment-256661319","issue_url":"https://api.github.com/repos/jwerts/jsapi4-angular2/issues/7","id":256661319,"user":{"login":"benitazz","id":3354516,"avatar_url":"https://avatars.githubusercontent.com/u/3354516?v=3","gravatar_id":"","url":"https://api.github.com/users/benitazz","html_url":"https://github.com/benitazz","followers_url":"https://api.github.com/users/benitazz/followers","following_url":"https://api.github.com/users/benitazz/following{/other_user}","gists_url":"https://api.github.com/users/benitazz/gists{/gist_id}","starred_url":"https://api.github.com/users/benitazz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benitazz/subscriptions","organizations_url":"https://api.github.com/users/benitazz/orgs","repos_url":"https://api.github.com/users/benitazz/repos","events_url":"https://api.github.com/users/benitazz/events{/privacy}","received_events_url":"https://api.github.com/users/benitazz/received_events","type":"User","site_admin":false},"created_at":"2016-10-27T14:41:52Z","updated_at":"2016-10-27T14:41:52Z","body":"I have checked and confirmed that my onClick method is being called, I even went as far as printing the layers before and after applying the new layer and can confirm that the map layers are being changed on the map object but for some other strange reason the new layers are not getting rendered. \r\n\r\nAs I have stated earlier its weird because addTileMapLayer only works in the constructor of the map service, the other weird part is that even after I created the map using the map service constructor and try to remove the layers then nothing happens, the same layer that I used on the constructor is still rendered but the map object does not have any layers.\r\n\r\nI have also created the method for monitoring which layers are being created or removed \r\n\r\nsomeOthermethod()\r\n.\r\n.\r\n.\r\n    this.map.allLayers.on(\"change\", this.onMapChanged);\r\n  }\r\n\r\n  private onMapChanged(event) {\r\n    debugger;\r\n    console.log(event);\r\n\r\n    if (event.added) {\r\n      event.added.forEach(data => { console.log(\"Added: title\" + data.title) });\r\n    }\r\n\r\n    if (event.removed) {\r\n      event.added.forEach(data => { console.log(\"Removed: title\" + data.title) });\r\n    }\r\n  }\r\n\r\n\r\n"}}
{"actor":{"display_login":"benitazz"}}