Describe
This example shows how to include a Dojo debug console in your app. You can write information to the console to record the events that occurred and the properties that were set when the app was run. This is extremely helpful when debugging an Internet Explorer browser error. (For Firefox, Firebug provides more debugging power than the Dojo Debug console.) )
You can add dojo debugging by setting the Isdebug property inside the Djconfig to true. You must set this option before referencing the ArcGIS JavaScript API:
<script type= "Text/javascript" >djconfig = {isdebug:true};</script>
<script type= "Text/javascript" src= "http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.1" ></script>
This example writes a message when the map is loaded, the map layer is added, and the map extent is modified. When the layer is incremented, an event listener writes a message to the console using the Console.log method:
Dojo.connect (Map, "Onlayeradd", function () {Console.log ("Layer added");})
Note You can also send a set of properties to the console by using the Tojson method. This line of code conveniently writes the properties of all scopes on the console:
Dojo.connect (Map, "Onextentchange", function (extent) {Console.log ("extent changed:" + Dojo.tojson (Extent.tojson ()));} );
1 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD">2 <HTML>3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"/>5 <Metahttp-equiv= "X-ua-compatible"content= "Ie=7" />6 <title>Add a debug console</title>7 <Linkrel= "stylesheet"type= "Text/css"href= "Http://serverapi.arcgisonline.com/jsapi/arcgis/1.5/js/dojo/dijit/themes/tundra/tundra.css">8 <!--Declare Djconfig before including reference to ArcGIS JavaScript API -9 <Scripttype= "Text/javascript">Djconfig={isdebug:true };</Script>Ten <Scripttype= "Text/javascript"src= "http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.5"></Script> One <Scripttype= "Text/javascript"> A Dojo.require ("Esri.map"); - - functioninit () { the varMap= NewESRI. Map ("Map"); - dojo.connect (Map,"OnLoad",function(){ - Console.log ("Map Loaded"); - dojo.connect (Map,"Onextentchange",function(extent) { + Console.log ("Extent changed:" +Dojo.tojson (Extent.tojson ())); - }); + A }); at - dojo.connect (Map,"Onlayeradd",function(){ - Console.log ("Layer added"); - }); - Map.addlayer (NewEsri.layers.ArcGISTiledMapServiceLayer ("Http://server.arcgisonline.com/arcgis/rest/services/ESRI_StreetMap_World_2D/MapServer")); - } in - dojo.addonload (init); to </Script> + </Head> - <Bodyclass= "Tundra"> the Add Dojo Console window * <DivID= "Map"style= "width:512px; height:512px; border:1px solid #000;"></Div> $ </Body>Panax Notoginseng </HTML>
ArcGIS API for javascript--map configuration-Add a debug console <