Select to view content in your preferred language

Reordering ArcGISImageServiceLayer

5537
14
05-23-2016 02:15 AM
BryanSng1
Deactivated User

Hi guys,

Is there a way to reorder ArcGISImageServiceLayer (ArcGISImageServiceLayer | API Reference | ArcGIS API for JavaScript ) using the Map reorderLayer method (Map | API Reference | ArcGIS API for JavaScript ) ?

I notice that it will be created as

  <div> under <div> with class="esriMapLayers"

instead of

  <g> under <svg>

where all the feature layers are loaded into

I think this maybe the reason why reorderLayer does not work for ArcGISImageServiceLayer.

I'm ok with any method as long as I can do reordering of ArcGISImageServiceLayer with FeatureLayer.

Alternatively, is there any way I can display a raster image that support reordering?

Thanks!

0 Kudos
14 Replies
FC_Basson
MVP Alum

Do you want to manipulate the order of the image data sets in the Image Service? Then you will need to apply a mosaic rule on the Image Service (see ArcGISImageServiceLayer | API Reference | ArcGIS API for JavaScript  and MosaicRule | API Reference | ArcGIS API for JavaScript ).  The map reorderLayer function only applies to the layer order of the map and not the drawing order within a layer.

0 Kudos
BryanSng1
Deactivated User

Hmm not really, more like imagine I got the following layers for a train station:

1) Feature layer A to showcase [Toilet]

2) Feature layer B to showcase [Trash Bin]

3) Image layer C to showcase [Station Layout]

User can use a control to manipulate which layer should be on top of which one such that if I were to state that Image layer C is the last of them, then I will not be able to see Feature layer A and B since Image layer C will cover them.

0 Kudos
FC_Basson
MVP Alum

The layer order is index based with 0 being the bottom layer, so if you want to move a layer to the top then you can do it like this:

var fromtop = 0;  // layer order of visibility from the top
map.reorderLayer(layer, map.layerIds.length - 1 - fromtop);
0 Kudos
BryanSng1
Deactivated User

Hmm, yeah but unfortunately, that works only for the feature layers, image layer does not react to any reorderLayer call.

Most probably due to the way image layer render itself to the dom (separate div rather of g within svg)

0 Kudos
BryanSng1
Deactivated User

I realise that ArcGISImageServiceVectorLayer | API Reference | ArcGIS API for JavaScript is able to render raster layer as g within svg but unlike my feature layer, it is missing the path that are supposed to be in it.

Here's an example of the path:

<path fill="rgb(213, 242, 201)" fill-opacity="1" stroke="rgb(110, 110, 110)" stroke-opacity="1" stroke-width="0.5333333333333333" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="4" path="M 270,632 268,632 267,630 277,622 281,623 286,619 289,622 285,621 281,625 277,624 270,632" d="M 270 632 268 632 267 630 277 622 281 623 286 619 289 622 285 621 281 625 277 624 270 632" stroke-dasharray="none" dojoGfxStrokeStyle="solid" fill-rule="evenodd"></path>

Is there something special I should do to configure the image server or is it my js code?

My invocation is as follows:

var layer = new ArcGISImageServiceVectorLayer(url);
map.addLayer(layer);
0 Kudos
FC_Basson
MVP Alum

First issue with this question, you asked about an ArcGISImageServiceLayer, which is inherits from a different class (DynamicMapServiceLayer) than a ArcGISImageServiceVectorLayer (GraphicsLayer).  I think the graphics layers always render on top of the Dynamic layers, but if the layers you want to reorder are all from the Graphics layer type, you should still be able to reorder them.  See this fiddle - click the switch button and layer order changes.

BryanSng1
Deactivated User

The difference between the 2 layers type is good information. This assure me that using ArcGISImageServiceVectorLayer is the right way to go in order to play well in reordering with feature layers.

Now I would need to find out how to display the image layer as it always does not render. The online api states that:

The ArcGISImageServiceVectorLayer displays pixel values as vectors. To do this, the image service layer must be a two-band raster in which one band holds magnitude values and one band holds direction values. The ArcGISImageServiceVectorLayer also supports time-enabled data.

Currently my image layer has 3 bands (auto created when I import the image into ArcMap), do you think this is the problem?

0 Kudos
FC_Basson
MVP Alum

I would think so.  Try loading a single band of the image layer.

0 Kudos
BryanSng1
Deactivated User

Hmm so far I hasn't had much luck with 1 band raster (by converting 3 band raster into 1 band raster). I also notice that the online article mention magnitude and direction values, I thought band should be holding color values?

0 Kudos