Esri / arcgis-js-vscode-snippets

Collection of Visual Studio Code snippets for common code patterns in the ArcGIS Maps SDK for JavaScript.
https://marketplace.visualstudio.com/items?itemName=Esri.arcgis-maps-sdk-js-snippets
Apache License 2.0
25 stars 8 forks source link

Snippet proposal: Find a layer by it's name #16

Closed hhkaos closed 3 years ago

hhkaos commented 3 years ago

I took the idea from this script that Maarten from Esri Netherlands published on its CoolScripts repo.


Prefix: findLayer Description: Snippet:

const fl = view.map.layers.find( l => l.title === "${1:LayerTitle}");

Code:

"Find a layer by it's name": {
    "prefix": "findLayer",
    "body": [
    "const fl = view.map.layers.find( l => l.title === \"${1:LayerTitle}\");",
    ],
    "description": ""
}
kellyhutchins commented 3 years ago

This looks like a useful snippet. We'll just want to remove the const fl to fit with the standards we discussed earlier.

hhkaos commented 3 years ago

Yep!, you are right!

RalucaNicola commented 3 years ago

useful indeed!

so only view.map.layers.find( l => l.title === "${1:LayerTitle}"); with the prefix findLayer sounds great to me

hhkaos commented 3 years ago

PR done!