AnsweredAssumed Answered

Get Layer Name

Question asked by csergent08 Champion on Dec 12, 2012
Latest reply on Dec 12, 2012 by csergent08
I am attempting to display the name of a layer in an alert box. I have attached the .NET project. Here is the JavaScript code that I am using with a comment above the line where I am attempting to get the name of the layer. Any ideas what I need to do? :
<script type="text/javascript">
        dojo.require("esri.map");
        dojo.require("esri.layers.agstiled"); // cached map service.
       

        var map;

        function init() {
            map = new esri.Map("mapDiv");
           
            dojo.connect(window, 'resize', map, map.resize);

            var baseMapURL = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer";
            var basemap = new esri.layers.ArcGISTiledMapServiceLayer(baseMapURL);

            map.addLayer(basemap);
            // I want this alert to display the layer name which should be Topographic Info.
            alert(basemap.layerInfos[0].name);       
           
        }
        dojo.addOnLoad(init);
       
       
    </script>


Thanks.

Chris S.

Attachments

Outcomes