breilly47

esri.layers.FeatureLayer is not a constructor error

Discussion created by breilly47 on Jun 27, 2011
Latest reply on Jun 27, 2011 by DSwingley-esristaff
I'm trying to add a layer to a javascript map, but I keep getting an error that esri.layers.FeatureLayer is not a constructor. I can only find one post about this, where that person was not using dojo.addOnLoad. I've included my code- what is causing this?

<head>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.3" type="text/javascript"></script>
<link href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.3/js/dojo/dijit/themes/claro/claro.css" rel="stylesheet" type="text/css" >

<script type="text/javascript">
  dojo.require("esri.map");
  dojo.require("esri.layers.FeatureLayer");
  var map;
  var campus;
function init() {
  map = new esri.Map("mapDiv");
  var spatialRef = new esri.SpatialReference({wkid:4326});
  var startExtent = new esri.geometry.Extent();
  startExtent.xmin = -88.7491;
  startExtent.ymin = 42.8345;
  startExtent.xmax = -88.7368;
  startExtent.ymax = 42.8433;
  startExtent.SpatialReference = spatialRef;


  map.setExtent(startExtent);
  var mapServiceURL = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer";
  map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer(mapServiceURL));
  
  campus = new esri.layers.FeatureLayer("http://[SERVER]/ArcGIS/rest/services/campusjava1/MapServer/0");


}


  dojo.addOnLoad(init);
  
</script>
</head>
<body OnLoad="init()" class="claro">
  <div id="mapDiv" style="width:1000px; height:800px; border:1px solid #000;"></div>
</body>

Outcomes