Two WmsDynamicMapServiceLayer ?

842
3
04-12-2017 02:26 AM
MohammadAlmalt
New Contributor

Is there a way to put two WmsDynamicMapServiceLayer on top of eachother where both are transparent ?

0 Kudos
3 Replies
nita14
by
Occasional Contributor III

Mohammed,

why don't you create two instances of WmsDynamicMapServiceLayer pointing to differents wms service endpoints?

Regards,

Adam

0 Kudos
MohammadAlmalt
New Contributor

Hi Adam,

I did that, but only 1 layer is displayed at a time.

String url = "first url";

WmsDynamicMapServiceLayer wmsLayer =
            new WmsDynamicMapServiceLayer(url, new String[] { "0"});
        wmsLayer.setTransparent(true);
        wmsLayer.setImageFormat("png");
        wmsLayer.setVisible(true);
        wmsLayer.setOpacity(0.99f);
        layers.add(wmsLayer);

url = "second url";

wmsLayer =
            new WmsDynamicMapServiceLayer(url, new String[] { "0"});
        wmsLayer.setTransparent(true);
        wmsLayer.setImageFormat("png");
        wmsLayer.setVisible(true);
        wmsLayer.setOpacity(0.99f);
        layers.add(wmsLayer);

When I comment the first layers.add(wmsLayer); then the second one is displayed on the map

When I comment the second layers.add(wmsLayer); then the first one is displayed on the map

When I want both to be displayed it does not happen

Is there a solution?

0 Kudos
nita14
by
Occasional Contributor III

Mohammad,

As I said - " create two instances of WmsDynamicMapServiceLayer",

create 

WmsDynamicMapServiceLayer wmsLayer1  = new WmsDynamicMapServiceLayer(url, new String[] { "0"});

and WmsDynamicMapServiceLayer wmsLayer2 = new WmsDynamicMapServiceLayer(url, new String[] { "0"});

 

then set visibilty to those. As so far you override the first layer by the definiotion of the second one.

Regards,


Adam

0 Kudos