0

here is my code to display toc.Its displaying dynamic layers but why its not displaying feature layers.

<!DOCTYPE html>  
<html>  
<head>  
    <title>Create a Map</title>  
    <meta http-equiv="content-type" content="text/html; charset=utf-8">  
    <meta name="viewport" content="initial-scale=1,maximum-scale=1, user-scalable=no">  
    <link rel="stylesheet" href="http://js.arcgis.com/3.11/dijit/themes/soria/soria.css">  
    <link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css">  
    <!--<link href="agsjs/dijit/css/TOC.css" rel="stylesheet" type="text/css" />-->  
    <link rel="stylesheet" type="text/css" href="http://gmaps-utility-gis.googlecode.com/svn/tags/agsjs/latest/build/agsjs/css/agsjs.css" />  
    <style>  
        html, body, #mapDiv {  
            padding: 0;  
            margin: 0;  
            height: 100%;  
            width: 100%;  
            overflow: hidden;  
        }  


        #tocDiv {  
            z-index: 50;  
            position: absolute;  
            top: 0%;  
            left: 0%;  
            width: 300px;  
            height: auto;  
            background-color: White;  
        }  

        #scaleDiv .agsjsTOCOutOfScale {  
            display: none;  
        }  

        #divDialogProcess {  
            z-index: 50;  
            position: absolute;  
            right: 0%;  
            top: 0%;  
            background-color: White;  
        }  
    </style>  
    <script>  
        var dojoConfig = {  
            packages: [{  
                name: "agsjs",  
                "location": 'http://gmaps-utility-gis.googlecode.com/svn/tags/agsjs/latest/build/agsjs' // for xdomain load  
            }]  
        };  
    </script>  


    <script src="http://js.arcgis.com/3.11/"></script>  
    <script>  
        var map, tiled, pointFeatureLayer, operationalLayer;  
        require(["esri/map", "esri/config",  
                 "esri/geometry/Extent",  
                 "esri/layers/ArcGISDynamicMapServiceLayer",  
                 "esri/layers/FeatureLayer",  
                 "esri/renderers/ClassBreaksRenderer",  
                 "esri/symbols/SimpleFillSymbol",  
                 "esri/tasks/GeometryService",  
                 "dojo/dom",  
                 "dojo/dom-geometry",  
                 "dojo/fx",  
                 "dojo/on",  
                 "dojo/parser",  
                 "dojo/_base/Color",  
                 "agsjs/dijit/TOC",  
                 "dojo/domReady!"], function (Map, esriConfig, Extent, ArcGISDynamicMapServiceLayer, FeatureLayer, ClassBreaksRenderer, SimpleFillSymbol, GeometryService, dom, domGeom, coreFx, on, parser, Color, TOC  
        ) {  

                map = new Map("mapDiv", {
                 center: [77.2, 14],
                 zoom: 7,
                 basemap: "streets",
                 slider: false,

             });

                     operationalLayer = new ArcGISDynamicMapServiceLayer("http://164.100.133.131/arcgisserver/rest/services/CRD/CRD1/MapServer", { id: "Operational", opacity: 0.5 });  

                     pointFeatureLayer = new FeatureLayer("http://164.100.133.131/arcgisserver/rest/services/CRD/CRD2/FeatureServer", { id: "Points" });  

                     map.addLayers([operationalLayer, pointFeatureLayer]);  

                     // Add Table of Contents Start  
                     map.on('layers-add-result', function (evt) {  
                         try {  
                             var toc = new TOC({  
                                 map: map,  
                                 layerInfos: [{  
                                     layer: pointFeatureLayer,  
                                     title: "My Feature"  
                                 }, {  
                                     layer: operationalLayer,  
                                     title: "Dynamic Map"  
                                 }]  
                             }, "tocDiv");  
                             toc.startup();  

                             toc.on("load", function () {  
                                 console.log("TOC loaded");  
                             });  
                         }  
                         catch (e) { console.error(e.message); }  


                     });  
                 }  
        );  
    </script>  
</head>  
<body class="soria">  
    <div id="mapDiv">  
        <div id="tocDiv"></div>  
    </div>  
</body>  
</html>  

Can any one tell whats wrong in the above code?

  • Please take the tour which gives an overview of how this site works and leads into a more detailed help center. – PolyGeo Jan 13 '16 at 7:34
1

A FeatureLayer shows a single layer in a service, which you have to include in its constructor. You have to specify the GridPoint layer (0)

pointFeatureLayer = new FeatureLayer("http://164.100.133.131/arcgisserver/rest/services/CRD/CRD2/FeatureServer/0", { id: "Points" });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.