turn map/feature services on and off

1388
13
05-30-2014 06:45 AM
jaykapalczynski
Frequent Contributor
Looking through the online Samples for ArcGIS JavaScript API for examples and documentation for turning on and off Map/Feature services I have in my application

Anyone help point me in the right direction.

Thanks
0 Kudos
13 Replies
jaykapalczynski
Frequent Contributor
0 Kudos
KenBuja
MVP Esteemed Contributor
The simplest are these two samples. A slightly more complex example that has checkboxes for different services is here. From there you could look at a Table of Contents control like this.
0 Kudos
jaykapalczynski
Frequent Contributor
I am looking at the example above...I removed the examples REST Endpoint and replaced with mine and it no longer works....
Confused...
Anyone have any thoughts....replaced with this.


          layer = new ArcGISDynamicMapServiceLayer("https://fwisweb1.dgif.virginia.gov/arcgis/rest/services/Public/BirdingWildlifeTrail/MapServer",
            {"imageParameters": imageParameters});
          map.addLayer(layer);
0 Kudos
jaykapalczynski
Frequent Contributor
I was able to look at your check box example and get working with my Map Service....thanks

I have one more question....Because I am referencing multiple Features in the Map Service at ONE time how do I define the multiple infoTemplates to be used in an identify?

I was using this on single Map Services
var templateBirdingTrailHeads = new InfoTemplate();
templateBirdingTrailHeads.setTitle("Birding Trail Heads");
templateBirdingTrailHeads.setContent("<table><tr><td><b>Loop Name</b></td><td>${LOOP_NAME}</td></tr></table>" +
     "<table><tr><td><b>Site Name</b></td><td>${SITE_NAME}</td></tr></table> " +
     "<table><tr><td><b>Pahse</b></td><td>${Phase}</td></tr></table> " 
);

 var flBirdingTrailHeads = new FeatureLayer("https://fwisweb1.gov/arcgis/rest/services/Public/BirdingWildlifeTrail/MapServer/0", {
         mode: FeatureLayer.MODE_ONDEMAND,
         infoTemplate: templateBirdingTrailHeads,
         outFields: ['*']
    });
 app.map.addLayer(flBirdingTrailHeads);


But now I have all the Features in the one Map Service

var layer1 = new ArcGISDynamicMapServiceLayer("https://fwisweb1.gov/arcgis/rest/services/Public/BirdingWildlifeTrail/MapServer", { id: "layer1" });

    app.map.addLayers([layer1]);

0 Kudos
KenBuja
MVP Esteemed Contributor
Here's an example that uses different templates on the same layer. You should be able to use the same logic to determine which layer is being shown in the infoWindow and use the correct template.
0 Kudos
jaykapalczynski
Frequent Contributor
I see where you are going with that...but all three layers could be being displayed at the same time.  not one or the other as I think you are proposing...


  1. right now the app opens and the three layers a displayed.

  2. I can turn them on and off individually with the check box.

  3. But as stated above they might all be on...



That make sense?....I can create a JSFiddle is necessary
0 Kudos
jaykapalczynski
Frequent Contributor
Here is a JSFiddle of my issue.
http://jsfiddle.net/vCW8W/5/

The layer list is being created from the Map Service that I am referencing. 

I want to add an Identify.  Normally I create an infoTemplate for each Service to feed a container to display the results.
But in this case I am only referencing the Map Service as a whole.
There was a comment to figure out which item was checked and then apply a specific infoTemplate.  BUT in my case 1, 2, or all three could be displayed at any given moment.

How do I define the template for each layer in the Service in this case?  Maybe something in the identify function that determines which Layer in the Service was selected?

Thanks
0 Kudos
jaykapalczynski
Frequent Contributor
Just not sure how to set up an infoTemplate for each of the Map services when done this way....

Unless there is another way to build a list of Layers and put them in a container to turn on and off?  Noting that all or and variation may be displayed at any given moment.  I love the ability to build the list automatically but need to identify on these layers as well.

Any thoughts?
0 Kudos
jaykapalczynski
Frequent Contributor
Looking at your example again I think I know what you were getting at....going to try a few things....brb
0 Kudos