Select to view content in your preferred language

Javascript api

1194
4
Jump to solution
07-25-2014 12:34 PM
ChrisHolmes
Frequent Contributor


Hello, I am new to working with the api so have started with the "Build your first application" https://developers.arcgis.com/javascript/jstutorials/intro_firstmap.html

I think I have all of the text correct, but what I end up with is the following in the browser:

var map; function init() { map = new esri.Map("mapDiv", { center: [-56.049, 38.485], zoom: 3, basemap: "streets" }); } dojo.ready(init);

Here is a copy of my file:

<!DOCTYPE html>

<html>

  <head>

  <title>Create a Map</title>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">

  <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/claro/claro.css">

  <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">

  <script src="http://js.arcgis.com/3.10/"></script>

  <style>

   html, body, #mapDiv {

    padding: 0;

    margin: 0;

    height: 100%;

   }

  </style>

 

 

  <script>

   dojo.require("esri.map");

   function init() {

    var map = new esri.Map("mapDiv", {

    center: [-56.049, 38.485],

    zoom: 3,

    basemap: "streets"

   });

   }

   dojo.ready(init);

  </script>

 

</head>

<body class="claro">

  <div id="mapDiv"></div>

</body>

</html>

Any ideas as to what I am missing are appreciated. Thanks!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
TimWitt2
MVP Alum

Chris,

you should start using the following code (AMD), the code you are using is legacy, which will soon " go away".

<!DOCTYPE html>

<html>

<head>

  <title>Create a Map</title>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">

  <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/claro/claro.css">

  <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">

  <style>

    html, body, #mapDiv{

      padding: 0;

      margin: 0;

      height: 100%;

    }

  </style>

  <script src="http://js.arcgis.com/3.10/"></script>

  <script>

    var map;

    require(["esri/map", "dojo/domReady!"], function(Map) {

      map = new Map("mapDiv", {

        center: [-56.049, 38.485],

        zoom: 3,

        basemap: "streets"

      });

    });

  </script>

</head>

<body class="claro">

  <div id="mapDiv"></div>

</body>

</html>

Hope this helps!

Tim

View solution in original post

0 Kudos
4 Replies
TimWitt2
MVP Alum

Chris,

you should start using the following code (AMD), the code you are using is legacy, which will soon " go away".

<!DOCTYPE html>

<html>

<head>

  <title>Create a Map</title>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">

  <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/claro/claro.css">

  <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">

  <style>

    html, body, #mapDiv{

      padding: 0;

      margin: 0;

      height: 100%;

    }

  </style>

  <script src="http://js.arcgis.com/3.10/"></script>

  <script>

    var map;

    require(["esri/map", "dojo/domReady!"], function(Map) {

      map = new Map("mapDiv", {

        center: [-56.049, 38.485],

        zoom: 3,

        basemap: "streets"

      });

    });

  </script>

</head>

<body class="claro">

  <div id="mapDiv"></div>

</body>

</html>

Hope this helps!

Tim

0 Kudos
ChrisHolmes
Frequent Contributor

Thanks for the help Tim!

0 Kudos
BjornSvensson
Esri Regular Contributor
ChrisHolmes
Frequent Contributor

Thanks for the link Bjorn!

0 Kudos