Select to view content in your preferred language

Browser Crashing using too many checkboxes

859
2
06-26-2014 06:26 AM
StevenGraf1
Frequent Contributor
Hello, I have 15 feature layers and I am appending a check box to each one so I can turn them on and off.  My services are secured and after I log in my browser takes a while to load and then crashes. Any idea why this is happening?

var layer0 = new FeatureLayer("https://myserver/FeatureServer/0", {
  mode: FeatureLayer.MODE_ONDEMAND,
        infoTemplate: layer0Template,
        outFields:["*"]  
  });

  map.addLayer(layer0);
  layer0.setVisibility(false);

  var checkBox = new CheckBox({
        name: "checkBox0",
        value: "agreed",
        checked: false,
        onChange: function(b){
    if (b == true) {
     layer0.setVisibility(true);
    } else {
     layer0.setVisibility(false);
    } }
  }, "checkBox0").startup();  
  
    
  var layer1 = new FeatureLayer("https://myserver/FeatureServer/1", {
  mode: FeatureLayer.MODE_ONDEMAND,
        infoTemplate: layer0Template,
        outFields:["*"]  
  });

  map.addLayer(layer1);
  layer1.setVisibility(false);
  
  var checkBox1 = new CheckBox({
        name: "checkBox1",
        value: "agreed",
        checked: false,
        onChange: function(b){
    if (b == true) {
     layer1.setVisibility(true);
    } else {
     layer1.setVisibility(false);
    } }
  }, "checkBox1").startup();


In the chrome developer tools it says this a bunch of times:

Error
info: 0
message: "defineAlreadyDefined"
src: "dojoLoader"
stack: (...)
get stack: function () { [native code] }
set stack: function () { [native code] }
__proto__: d

Error
"Error
    at Error (native)
    at Object.f.load (https://js.arcgis.com/3.9/init.js:629:424)
    at https://js.arcgis.com/3.9/init.js:187:69
    at c (https://js.arcgis.com/3.9/init.js:74:221)
    at d (https://js.arcgis.com/3.9/init.js:74:10)
    at resolve.callback (https://js.arcgis.com/3.9/init.js:75:350)
    at c (https://js.arcgis.com/3.9/init.js:74:436)
    at d (https://js.arcgis.com/3.9/init.js:74:10)
    at resolve.callback (https://js.arcgis.com/3.9/init.js:75:350)
    at https://js.arcgis.com/3.9/init.js:191:300"
0 Kudos
2 Replies
StevenGraf1
Frequent Contributor
So from doing some research, these messages are caused because I am accessing secure services.

I still can't figure out why my application crashes my browser.  The code above is just a small snippet.  I have 15 feature layers that use the above code.

I am no longer getting this error
Error
info: 0
message: "defineAlreadyDefined"
src: "dojoLoader"
stack: (...)
get stack: function () { [native code] }
set stack: function () { [native code] }
__proto__: d

but I am getting this (accessing secured resources is what I think is causing it)

Error
code: 499
details: Array[0]
httpCode: 499
log: undefined
message: "Token Required"
stack: "Error�?�    at Error (native)�?�    at Object.f.load (https://js.arcgis.com/3.9/init.js:629:424)�?�    at https://js.arcgis.com/3.9/init.js:187:69�?�    at c (https://js.arcgis.com/3.9/init.js:74:221)�?�    at d (https://js.arcgis.com/3.9/init.js:74:10)�?�    at resolve.callback (https://js.arcgis.com/3.9/init.js:75:350)�?�    at c (https://js.arcgis.com/3.9/init.js:74:436)�?�    at d (https://js.arcgis.com/3.9/init.js:74:10)�?�    at resolve.callback (https://js.arcgis.com/3.9/init.js:75:350)�?�    at https://js.arcgis.com/3.9/init.js:191:300"
__proto__: d

Anyone have any ideas? Thanks!
0 Kudos
StevenGraf1
Frequent Contributor
Well I know my issue now.  The size of my data is causing the issue.

Came across some blog posts from Derek that explains some ways to work with large datasets.

Here is the link for some best practices using feature layers.
0 Kudos