dojo.connect(map, 'onLayerAdd', function(){ alert(basemap.layerInfos[0].name); }); map.addLayer(basemap);
You'll want to listen to the 'onLayerAdd' event when adding individual layers.http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/map.htm#onLayerAddSo something likedojo.connect(map, 'onLayerAdd', function(){ alert(basemap.layerInfos[0].name); }); map.addLayer(basemap);Right now you're trying to access the layerInfos immediately after adding it to the map, but you have to wait for it to finish loading before you can interact with it.You might even be able to listen to the individual layers onLoad, but I haven't tried that way.http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/layer.htm#onLoad
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.