In the previous blog, we have described how to build an ArcGIS API for JavaScript development environment, if you have not yet set up a development environment, refer to the blog: http://blog.csdn.net/zdw_wym/article/details/48678913.
If the development environment is set up, today we continue to build our first ArcGIS API for JavaScript application.
The following first paste the code out and copy it into the new HTML page in VS2012.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">Run as follows:
Next we focus on the following JS code, which uses the AMD approach: <script type= "Text/javascript";
& nbsp VAR map;
require (["esri/map "," dojo/domready! "], function (map) {
map = new map ("map", {
&NBSP ; Basemap: "Topo",
cent ER: [118.932036047149, 32.09141405],
Zoom:
});
});
</script>
Use ESRI's preferences when naming parameters in the Require callback function. In the above code, a reference to the Esri/map resource is provided, and then in the internal anonymous function, a map preference is provided, and each resource referenced in the Require function has a corresponding parameter to provide access to the resource object.
The outdated wording is as follows:
<script type= "Text/javascript";
dojo.require ("esri.map ");
function init () {
& nbsp var map = new ESRI. Map ("Map", {
Basemap: "Topo",
&N Bsp Center: [118.932036047149, 32.09141405],
& nbsp ZOOM:10
});
}
dojo.ready ( Init );
&NBSP;</SCRIPT> Dojo.require has not been recommended, the official document is recommended to use require, as for the module name delimiter is only a grammar requirements.
The first sample program for creating ArcGIS API for JavaScript