Raster Layers in Flex Viewer

3406
6
Jump to solution
10-16-2014 06:53 AM
MaureenKerr
New Contributor II

Hi

I was wondering is there a way to add Raster Datasets to a viewer in the same way that feature layers can be added.  So I have 30 jpegs to publish, I would rather that they are all published in 1 Map Service rather than have 30 Map Services but when adding them to the flex viewer I need to have them as separate layers that can be turned on and off, individually zoomed to and transparency adjusted individually as some of the rasters overlap.  I know that this can be done with feature layers by changing the type from dynamic to feature and adding the published layer number at the end of the url in the config so I was wondering how I would go about doing the same for separate Raster layers?

Thanks

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Maureen,

   You would set the type for each of those layers to "dynamic". Here is an example of using a definitionexpression:

<layer label="USA Federal Lands-Reservations" 
  type="dynamic" visible="false" alpha=".7" showinlegendhiddenlayers="1" visiblelayers="2"
  url="http://maps1.arcgisonline.com/ArcGIS/rest/services/USA_Federal_Lands/MapServer">
  <sublayer id="2" definitionexpression="AGBUR = 'BIA'"/>
</layer>

View solution in original post

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus

Maureen,

  FeatureLayer does not support rasters so you can not add them as individual FeatureLayers. You could add an ArcGISDynamicMapServiceLayer and set a definitionexpression that would limit the layer to one individual raster in your map service and then repeat for all 30.

0 Kudos
MaureenKerr
New Contributor II

Hi Robert

Thank you for getting back to me so quickly, it certainly sounds like what I need but  I'm a bit unclear as to what you mean by ArcGISDynamicServiceLayer do you mean when I add the URL to the config file I need to change the type or is there something before that that I am missing.  Also would you able to give me some examples of how the definitionexpression would be written using the information in the attribute table? 

Thanks

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Maureen,

   You would set the type for each of those layers to "dynamic". Here is an example of using a definitionexpression:

<layer label="USA Federal Lands-Reservations" 
  type="dynamic" visible="false" alpha=".7" showinlegendhiddenlayers="1" visiblelayers="2"
  url="http://maps1.arcgisonline.com/ArcGIS/rest/services/USA_Federal_Lands/MapServer">
  <sublayer id="2" definitionexpression="AGBUR = 'BIA'"/>
</layer>
0 Kudos
MaureenKerr
New Contributor II

Hi Robert

Thanks a million! This is great, 99% what I am looking for, I was just wondering do you know of a way of getting it to zoom to the displayed layer rather than zoom to the whole extent of the webservice?

Maureen

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Maureen,

   No that is not going to be possible. The Definition Query does not update or affect the map services extent, so it will always return the original map service extent.

Glad I was able to help, now you can do your part by marking my response as the "Correct Answer". You do this by clicking on the "Correct Answer" link (the one with the little green star) on the reply that answered your question. You will see the "Correct Answer" link if you are looking at the the actual content page and not at the discussion from your inbox or your activity stream.

0 Kudos
MaureenKerr
New Contributor II

No Problem Robert, pity about the zoom to but I'll figure a way around that.

Thanks so much for your help!

0 Kudos