{"action":"created","issue":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/3528","repository_url":"https://api.github.com/repos/mapbox/mapbox-gl-js","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/3528/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/3528/comments","events_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/3528/events","html_url":"https://github.com/mapbox/mapbox-gl-js/issues/3528","id":186977653,"number":3528,"title":"Feature request: map.getLayerIds function","user":{"login":"voltagex","id":159567,"avatar_url":"https://avatars.githubusercontent.com/u/159567?v=3","gravatar_id":"","url":"https://api.github.com/users/voltagex","html_url":"https://github.com/voltagex","followers_url":"https://api.github.com/users/voltagex/followers","following_url":"https://api.github.com/users/voltagex/following{/other_user}","gists_url":"https://api.github.com/users/voltagex/gists{/gist_id}","starred_url":"https://api.github.com/users/voltagex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voltagex/subscriptions","organizations_url":"https://api.github.com/users/voltagex/orgs","repos_url":"https://api.github.com/users/voltagex/repos","events_url":"https://api.github.com/users/voltagex/events{/privacy}","received_events_url":"https://api.github.com/users/voltagex/received_events","type":"User","site_admin":false},"labels":[{"id":31015438,"url":"https://api.github.com/repos/mapbox/mapbox-gl-js/labels/enhancement","name":"enhancement","color":"0052cc","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-11-03T04:38:53Z","updated_at":"2016-11-03T21:22:17Z","closed_at":null,"body":"## Motivation\r\nCurrently, to get a reference to a layer on a map, you must run getLayer, passing in the ID of the layer. It would be easier in some cases to be able to get a list of all currently loaded layers (e.g. to loop/filter through them)\r\n\r\n## Design Alternatives\r\n* Continue with the current getLayer, require users to manually maintain list of layers\r\n* Create a getLayerIds that returns a list of layer ID strings, as most functions (e.g. setLayoutProperty) expect a string reference\r\n\r\n<!--\r\nHow could we accommodate the use cases above?\r\nIs \"do nothing\" an option?\r\n-->\r\n\r\n## Design\r\n\r\n\r\n### Mock-Up\r\n\r\n```\r\nmap.getLayerIds()\r\n> ['firstlayer', 'secondlayer', 'thirdlayer']\r\n```\r\n\r\n<!--\r\nWhat will this design look like to developers?\r\nWhat will this design look like to end users?\r\n-->\r\n\r\n### Concepts\r\n\r\n<!--\r\nHow will we teach this design?\r\nWhat terminology will work best for the new concepts introduced by this design?\r\nWhat existing precedents support the new concepts?\r\nWhere do the concepts set new precedents?\r\n-->\r\n\r\n### Implementation\r\n\r\n<!--\r\nHow you would implement the design in Javascript?\r\nHow you would implement the design in C++?\r\nWhat parts of the Mapbox GL ecosystem will need to change to accomodate this design?\r\nAre there any important edge cases?\r\n-->\r\n\r\n```js\r\nreturn map.style._order; // or\r\nreturn map.getStyle().layers.map((layer) => layer.id);\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/comments/258277938","html_url":"https://github.com/mapbox/mapbox-gl-js/issues/3528#issuecomment-258277938","issue_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/3528","id":258277938,"user":{"login":"voltagex","id":159567,"avatar_url":"https://avatars.githubusercontent.com/u/159567?v=3","gravatar_id":"","url":"https://api.github.com/users/voltagex","html_url":"https://github.com/voltagex","followers_url":"https://api.github.com/users/voltagex/followers","following_url":"https://api.github.com/users/voltagex/following{/other_user}","gists_url":"https://api.github.com/users/voltagex/gists{/gist_id}","starred_url":"https://api.github.com/users/voltagex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voltagex/subscriptions","organizations_url":"https://api.github.com/users/voltagex/orgs","repos_url":"https://api.github.com/users/voltagex/repos","events_url":"https://api.github.com/users/voltagex/events{/privacy}","received_events_url":"https://api.github.com/users/voltagex/received_events","type":"User","site_admin":false},"created_at":"2016-11-03T21:22:17Z","updated_at":"2016-11-03T21:22:17Z","body":"Wow, `map.getStyle().layers` returns an array of 199 objects for a simple test map. Is there really no distinction between basemap layers (e.g. streets-v9) and \"custom\" ones from my account?"}}
{"actor":{"display_login":"voltagex"}}