AnsweredAssumed Answered

About adding layers to LayerList

Question asked by endlessdsire on Oct 11, 2017
Latest reply on Aug 22, 2018 by endlessdsire

Hello there.

 

Im a little bit confused on how is the way to add layers into a LayerList obj. Im using Arcgis Api  3.17.

My code is the following:

 

var mapp = mymap.createMap("map","topo",-71.5215, -32.9934,9);

var interrClienteSED = new ArcGISDynamicMapServiceLayer(layers.read_dyn_layerClieSED(),{id:"po_interrupciones"});
interrClienteSED.setInfoTemplates({
3: {infoTemplate: myinfotemplate.getNisInfo()},
1: {infoTemplate: myinfotemplate.getIsolatedNisFailure()},
0: {infoTemplate: myinfotemplate.getSubFailure()}
});
interrClienteSED.refreshInterval = 1;
interrClienteSED.setImageFormat("png32");
interrClienteSED.show();

var chqmapabase = new ArcGISDynamicMapServiceLayer(layers.read_mapabase(),{id:"gis_chqmapabase"});
chqmapabase.hide();
var heatmapFeatureLayerOptions = {
id: "gis_heatmapsed",
mode: FeatureLayer.MODE_SNAPSHOT,
outFields: ["*"]
};
var heatmapFeatureLayerOptions2 = {
id: "gis_heatmapclientes",
mode: FeatureLayer.MODE_SNAPSHOT,
outFields: ["*"]
};
var heatmapFeatureLayer = new FeatureLayer(layers.read_heatmapSED(), heatmapFeatureLayerOptions);
var heatmapFeatureLayer1 = new FeatureLayer(layers.read_heatmapClientes(), heatmapFeatureLayerOptions2);
var heatmapRenderer = new HeatmapRenderer({
colors: ["rgba(0,255,0, 0)","rgb(255, 255, 0)","rgb(255, 0, 0)"],
blurRadius: 16,
maxPixelIntensity: 250,
minPixelIntensity: 5
});
heatmapFeatureLayer.setRenderer(heatmapRenderer);
heatmapFeatureLayer.hide();
heatmapFeatureLayer1.setRenderer(heatmapRenderer);
heatmapFeatureLayer1.hide();
var gpsCars = new ArcGISDynamicMapServiceLayer(layers.read_GPS(), {id:"gis_gps"});
gpsCars.setInfoTemplates({
0: {infoTemplate: myinfotemplate.getCarsInfo()}
});
gpsCars.refreshInterval = 0.1;
gpsCars.setImageFormat("png32");
gpsCars.show();
var gpsNew = new ArcGISDynamicMapServiceLayer(layers.read_gps_new(), {id:"gis_gps_new"});


mapp.addLayers([chqmapabase,interrClienteSED, heatmapFeatureLayer, heatmapFeatureLayer1, gpsCars]);
var layerList = new LayerList({
map: mapp,
showLegend: true,
showSubLayers: true,
showOpacitySlider: true,
layers: [interrClienteSED, gpsCars]
},"layerlist");

layerList.startup();

 

Then i have only this in my html:

 

<div className="map_container">
    <div id="layerlist"></div>
    <div id="map"></div>
    <Simbology />
</div>

 

The result i have is this one:

 

I was trying with the layers that i already have added in the map, but actually i want to use another service where i have sublayers according this structure:

Layers :
 One (0)

   • One - 1 (1)

Two (3)
   • Two - 2 (4)

 

I want to see in the layerlist all of them, see the legend and turn on/off each one.

 

Thanks in advice!.

Outcomes