1

I'm customizing the cmv viewer to works with my services. I have service that have 3 layer (0,1,2) and is a dynamic map service layer. It's possible to set only one layer to show?

1

If you want to only allow the user to choose one layer, for example layer id 1, I think you will want to use the Image Parameters class.

Create a function in your config file (viewer.js)

// Allows user to hide layers in Dynamic map service
function buildImageParameters (config) {
   var ip = new ImageParameters();
   for (var key in config) {
       if (config.hasOwnProperty(key)) {
           ip[key] = config[key];
       }
   }
   return ip;
}

And in your dynamic layer options:

imageParameters: buildImageParameters({
               format: 'png32',
               layerIds: [1],
               layerOption:  ImageParameters.LAYER_OPTION_EXCLUDE
            })

This will allow you to only show one layer in the app from that service.

Details Here

Or modify cmv to allow this directly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.