Limiting layers on a map

1591
1
02-26-2016 03:25 PM
NeemaGudur
New Contributor

I am using the FEMA flood base map service located at

public/NFHL (MapServer)

This base map service has many layers. I am interested in layers 3,27 and 28.

I tried limiting the layers using the following code

var imageParameters = new ImageParameters();

imageParameters.layerIds = [3,27,28];

imageParameters.layerOption = ImageParameters.LAYER_OPTION_SHOW;

  imageParameters.transparent = false;

var dynamicMapServiceLayer = new EsriArcGISDynamicMapServiceLayer(oneLayer.url,{"ImageParameters": imageParameters});

map.addLayer(dynamicMapServiceLayer);

The request goes out to FEMA as below.

http://hazards.fema.gov/gis/nfhl/rest/services/public/NFHL/MapServer/export?dpi=96&transparent=true&...

The correct request should be as below requesting only the layers needed

http://hazards.fema.gov/gis/nfhl/rest/services/public/NFHL/MapServer/export?dpi=96&transparent=true&...

Do I need to modify add something to my code snippet in order to request the only the layers that I need/

Any help is appreciated.

Thanks

Neema

Reply
0 Kudos
1 Reply
KenBuja
MVP Honored Contributor

You have the syntax wrong when you construct the dynamic layer. You're using "ImageParameters" when you have to use "imageParameters". Instead of

var dynamicMapServiceLayer = new EsriArcGISDynamicMapServiceLayer(oneLayer.url,{"ImageParameters": imageParameters});

you have to use this

var dynamicMapServiceLayer = new EsriArcGISDynamicMapServiceLayer(oneLayer.url,{"imageParameters": imageParameters});

Reply
0 Kudos