ArcGIS API for javascript--map configuration-Add a debug console <

Source: Internet
Author: User
Tags event listener tojson

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 <

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.