esri.layers.FeatureLayer is not a constructor

2109
2
08-12-2010 07:42 AM
BenoitFrébault
New Contributor
Hi,

I have a problem when I want create a FeatureLayer. Firebug show me this error :

esri.layers.FeatureLayer is not a constructor
    outFields: ["ID_SVG", "Communaute", "ID_Groupe", "ID_REGION", carte.varia]

I don't understand why, because esri.layers.FeatureLayer IS a constructor. And half the time, it's work, no error and my layer is displayed correctly.

This is my code to create the FeatureLayer :

comLayer = new esri.layers.FeatureLayer(urlCom,{
  mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
  outFields: ["ID_SVG", "Communaute",  "ID_Groupe", "ID_REGION", carte.varia]
});

Thanks for your help.

Benoît
0 Kudos
2 Replies
BenoitFrébault
New Contributor
I come back with this problem because it's very annoying.I don't understand this error and I don't know where the problem can be.

My application doesn't work with IE, Chrome and Safari but it's works half the time with Firefox and Opera..
My server is IIS7.5 and the version of ArcGis Server is 9.3.
The version of my ArcGis Api for JS is 2.0.

At the beginning of my script., I call
dojo.require("esri.layers.FeatureLayer");


My variable urlCom is defined in a switch case, but it looks all the time like this. Only comJoin change.
var urlCom = "http://arcgisserveur/ArcGIS/rest/services/comJoin/MapServer/0";


I have an other problem may be it's linked. My zoom slider is not the classical, it's a grey square on  a red bar.

My web application is almost finish and I don't want to say to my future users that only  works with Firefox or Opera and you must refresh the page if the map doesn't show.

So if someone have an idea about the problem, please don't hesitate to tell me.

Thanks you
0 Kudos
RodolfoOrtiz
New Contributor
Hi Benoit,

I was getting the same error "esri.layers.FeatureLayer is not a constructor" and it was because esri.layers.FeatureLayer did not exist (the API was not loaded) when I was calling it. Instead of using dojo.addOnLoad I was using Ext.onReady (another JS API). I had to use dojo.addOnLoad to make sure that when I call esri.layers.FeatureLayer it is actually loaded.

-Rodolfo
0 Kudos