mshetzer

Map with Feature Layer not working (Windows Authenication)

Discussion created by mshetzer on Jun 26, 2012
I am trying to use the Map with Feature sample (below) and replacing the service "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3"   with my own that is running Windows Authentication in IIS.  I receive the login prompt, but the service does not display, and when I use Firebug, I am receiving 401 errors when hitting the service.  I use this service in Flex as well without any problems.  I know my login/password is correct because the folder in IIS is secured the same way. (3.0)


If I just use another sample with the whole service (not just one layer from the service) everything works just fine.

Any ideas ?

Thanks in advance,
Matt Shetzer




<!DOCTYPE html>
<html>
      <head>
            <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
            <meta name="apple-mobile-web-app-capable" content="yes" />
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
            <title>Feature Layer</title>
            <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.0compact"></script>

            <style type="text/css">
                  html, body {
                        height: 100%;
                        margin: 0px;
                        padding: 0px;
                        width: 100%;
                  }
                  #map {
                        height: 100%;
                        width: 100%;
                  }
                  .esriSimpleSlider  div {
                        height: 30px !important;
                        width: 30px !important;
                  }
            </style>

            <script type="text/javascript">
                  dojo.require("esri.map");
                  dojo.require("esri.layers.FeatureLayer");
                  dojo.require("esri.tasks.query");

                  var map;

                  function init() {
                        //onorientationchange doesn't always fire in a timely manner in Android so check for both orientationchange and resize
                        var supportsOrientationChange = "onorientationchange" in window, orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";

                        window.addEventListener(orientationEvent, function() {
                              orientationChanged();
                        }, false);

                        var initialExtent = new esri.geometry.Extent({
                              "xmin" : -11878390,
                              "ymin" : 4598298,
                              "xmax" : -11455847,
                              "ymax" : 5052028,
                              "spatialReference" : {
                                    "wkid" : 102100
                              }
                        });

                        map = new esri.Map("map", {
                              extent : initialExtent
                        });

                        var tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
                        map.addLayer(tiledMapServiceLayer);

                        dojo.connect(map, "onLoad", function(evt) {
                              //add a feature layer
                              var content = "<b>Name</b>: ${NAME} <br /><b>Population</b>: ${POP2007}";

                              var infoTemplate = new esri.InfoTemplate("County Details", content);
                              map.infoWindow.resize(225, 75);
                              var featureLayer = new esri.layers.FeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3", {
                                    mode : esri.layers.FeatureLayer.MODE_ONDEMAND,
                                    outFields : ["NAME", "POP2007"],
                                    infoTemplate : infoTemplate
                              });
                              var rend = new esri.renderer.SimpleRenderer(new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([254, 216, 93, .60])));
                              featureLayer.setRenderer(rend);

                              featureLayer.setSelectionSymbol(new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0, 255, 255, .60])));

                              dojo.connect(featureLayer, 'onClick', function(evt) {
                                    //select the clicked feature
                                    var query = new esri.tasks.Query();
                                    query.geometry = evt.mapPoint;
                                    featureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
                              });

                              map.addLayer(featureLayer);
                        });
                  }

                  function orientationChanged() {
                        console.log("Orientation changed: " + window.orientation);
                        if(map) {
                              map.reposition();
                              map.resize();
                        }
                  }

                  dojo.addOnLoad(init);
            </script>
      </head>

      <body >
            <div id="map"></div>
      </body>
</html>

Outcomes