archenil

FeatureLayer Declaration

Discussion created by archenil on Jan 4, 2012
Latest reply on Jan 4, 2012 by khutchins-esristaff
Hi,

I'm stuck in what seems to be an easy operation but couldn't figure out why the FeatureLayer  wouldn't display. If I comment out 'mode: esri.layers.FeatureLayer.MODE_SELECTION', CA counties show up just fine. Must be something I missed. Thanks for your help.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title>Some Map</title>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.6/js/dojo/dijit/themes/claro/claro.css">
    <style>
      html, body { height: 90%; width: 90%; margin: 0; padding: 0; }
      .esriScalebar{
        padding: 20px 20px;
      }
      #map{
        padding:0;
      }
    </style>
    <script type="text/javascript">var djConfig = {parseOnLoad: true};</script>
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.6"></script>
    <script type="text/javascript">
      dojo.require("dijit.layout.BorderContainer");
      dojo.require("dijit.layout.ContentPane");
      dojo.require("esri.map");
      dojo.require("esri.layers.FeatureLayer");
   dojo.require("esri.toolbars.draw");
   dojo.require("esri.tasks.query");
      
      var map;
      var featureLayer;
   
      function init() {
        var initExtent = new esri.geometry.Extent({"xmin":-14279583.76,"ymin":3721260.12,"xmax":-12078197.35,"ymax":5188851.07,"spatialReference":{"wkid":102100}});
        map = new esri.Map("map",{extent:initExtent});
     
        var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
        map.addLayer(basemap);
        
        featureLayer = new esri.layers.FeatureLayer("http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer/8", {
    mode: esri.layers.FeatureLayer.MODE_SELECTION,
    outFields: ["*"]
  });
        
        //apply a renderer
        var symbol = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,0,0,0.5]));
        var renderer = new esri.renderer.SimpleRenderer(symbol);
        featureLayer.setRenderer(renderer);
        
        //define a selection symbol
        var selectionSymbol = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,255,0,0.5]));
        featureLayer.setSelectionSymbol(selectionSymbol);
   
        map.addLayer(featureLayer);

        dojo.connect(map, 'onLoad', function(theMap) {
          //resize the map when the browser resizes
          dojo.connect(dijit.byId('map'), 'resize', map,map.resize);

        });
      }
   
      dojo.addOnLoad(init);
    </script>
  </head>
  
  <body class="claro">
    <div dojotype="dijit.layout.BorderContainer" design="headline" gutters="false" style="width: 100%; height: 100%; margin: 10;">
    <!--<div id="header" dojotype='dijit.layout.ContentPane' region='top' style='height:15%;'> -->
    <div id="map" dojotype="dijit.layout.ContentPane" region="center" style="border:solid 2px #587498;margin:5px;"/>
    </div>
  </body>

</html>

Outcomes