How to hide a map service layer? For a map service with 2 dozens of layers, I want to hide one of them from the TOC. Is there is an easy way to do it? Thanks.
I did another try by adding the function locally
function buildImageParameters (config) { var ip = new ImageParameters(); for (var key in config) { if (config.hasOwnProperty(key)) { ip[key] = config[key]; } } return ip;}
The 'Not found' error is gone. But with the defined
layerIds: [1,2,3,4,5],
layerOption: ImageParameters.LAYER_OPTION_EXCLUDE
the layer 0 still in the TOC. What's wrong in my code? Thanks.
I got runtime error when I use API 4.1. The problem may be the same as using 3.27 version. This could be the problem as I load several other API's that may cause some unknown conflicts. Thanks.
Tim: Thanks for your response. I use the code:
imageParameters: buildImageParameters({ ...
but got runtime error: JavaScript runtime error: 'buildImageParameters' is undefined
I DO use "http://js.arcgis.com/3.27compact/" as you do. But, for an unknown reason, this api can't be loaded in index.heml's <head></head> block, or else, the page can't be loaded. In the <head></head> block,I load several other api's (e.g. jquery and bootstrap's api).
This api has to be loaded after the dojoConfig like below, the the apge can be loaded properly.
<script type="text/javascript"> var dojoConfig = { async: true, packages: [{ name: 'viewer', location: location.pathname.replace(/[^\/]+$/, '') + 'js/viewer' }, { name: 'config', location: location.pathname.replace(/[^\/]+$/, '') + 'js/config' }, { name: 'gis', location: location.pathname.replace(/[^\/]+$/, '') + 'js/gis' }] };</script><script type="text/javascript" src="http://js.arcgis.com/3.27compact/"></script>
Could you provide your advisory to solve this problem? Thanks.
Shaning Yu if you're using a MapImageLayer, then you can define the visibility of the sublayer (map service layer).
Doc:
Sublayer | API Reference | ArcGIS API for JavaScript 4.10
Sample:
MapImageLayer - Toggle sublayer visibility | ArcGIS API for JavaScript 4.10
An example of this is provided in the demo code: cmv-app/viewer.js at develop · cmv/cmv-app · GitHub
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.