AnsweredAssumed Answered

creating javascript external file for map function

Question asked by MayMay on Sep 17, 2014
Latest reply on Sep 17, 2014 by Paulcrickard

I try to create a simple javascript external file.  I put all the require & function in one js file, it works. But how do you create another external js file for map function.

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title>Simple Map</title>
    <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">
    <link rel="stylesheet" href="css/layout.css">
    <script src="http://js.arcgis.com/3.10/"></script>
    <script type="text/javascript" src="script/init.js"></script>
  </head>

  <body>
    <div id="map"></div>
  </body>
</html>

 

---------------------------

layout.css

-------------------------------

 

      html, body, #map {

        height: 100%;

        width: 100%;

        margin: 0;

        padding: 0;

      }

      body {

        background-color: #FFF;

        overflow: hidden;

        font-family: "Trebuchet MS";

      }

 

-----------------

init.js

---------------

      var map;

      require(["esri/map", "dojo/domReady!"],function(Map) {
  map = new Map("map", {
          basemap: "topo",
          center: [-122.45, 37.75], // longitude, latitude
          zoom: 13
     });
        });

 

Thank you.
    

Outcomes