What's the correct syntax for adding multiple operationalLayers?

645
4
03-02-2013 02:17 PM
IB1
by
Occasional Contributor
I'm working off of a template and am trying to add multiple operationalLayers. I feel like I've tried every possible combination.

If I just add one layer, it works fine:

operationalLayers: [{
  type: "feature",
  url: "http://xxxxxx.com/arcgis/rest/services/xxx/xxx/FeatureServer/5",
  options: {
   id: "Fiber1",
   title: "Cable",
   opacity: 1.0,
   visible: true,
   infoTemplate: new esri.InfoTemplate(),
   mode: esri.layers.FeatureLayer.MODE_SNAPSHOT
  }
 }],


But when I try to add another, none of them load when I start the index.html:

operationalLayers: [{
  type: "feature",
  url: "http://xxxxxx.com/arcgis/rest/services/xxx/xxx/FeatureServer/5",
  options: {
   id: "Fiber1",
   title: "Cable",
   opacity: 1.0,
   visible: true,
   infoTemplate: new esri.InfoTemplate(),
   mode: esri.layers.FeatureLayer.MODE_SNAPSHOT
  }
  type: "feature",
  url: "http://xxxxxx.com/arcgis/rest/services/xxx/xxx/FeatureServer/4",
  options: {
   id: "Fiber2",
   title: "Junction",
   opacity: 1.0,
   visible: true,
   infoTemplate: new esri.InfoTemplate(),
   mode: esri.layers.FeatureLayer.MODE_SNAPSHOT
  }
 }],


What am I doing wrong here?

Thanks for any help.
0 Kudos
4 Replies
IB1
by
Occasional Contributor
Asked too soon! I figured it out. My brackets probably aren't how they are suppose to be location wise, but oh well.

operationalLayers: [
  {type: "feature",
  url: "http://xxxxxx.com/arcgis/rest/services/xxx/xxx/FeatureServer/5",
  options: {
   id: "Fiber1",
   title: "Cable",
   opacity: 1.0,
   visible: true,
   infoTemplate: new esri.InfoTemplate(),
   mode: esri.layers.FeatureLayer.MODE_SNAPSHOT
  }},
  {type: "feature",
  url: "http://xxxxxx.com/arcgis/rest/services/xxx/xxx/FeatureServer/4",
  options: {
   id: "Fiber2",
   title: "Junctions",
   opacity: 1.0,
   visible: true,
   infoTemplate: new esri.InfoTemplate(),
   mode: esri.layers.FeatureLayer.MODE_SNAPSHOT
  }}
],
0 Kudos
JianHuang
Occasional Contributor III
Just in case you don't know this:
jsonlint.com
0 Kudos
IB1
by
Occasional Contributor
Just in case you don't know this:
jsonlint.com


As a noob, how would that have helped me? Thanks.
0 Kudos
DianaBenedict
Occasional Contributor III
As a noob, how would that have helped me? Thanks.


It would indicate to you if your json was fomatted corretly. Basically it would have indicated to you that you had the parens incorrectly placed.
0 Kudos