ArcGIS API for JavaScript Tutorial not working ?!

975
5
10-11-2013 12:12 AM
AlexandreECUVILLON1
New Contributor III
I'm trying the second basic tutorial : https://developers.arcgis.com/en/javascript/jstutorials/intro_agstemplate_amd.html
The code doesn't work, even in the sandbox : http://developers.arcgis.com/en/javascript/sandbox/sandbox.html?sample=map_webmap (map is blank)

I've tested it with IE9 and FF24 ; same results !

Where is the problem ? Sample codes aren't right ?

Thanks for your help.
Alex.
0 Kudos
5 Replies
AlexandreECUVILLON1
New Contributor III
I have found where the problem is : the code of http://developers.arcgis.com/en/javascript/sandbox/sandbox.html?sample=map_webmap is buggy :
- line 36 : it's "webmapId", not "webapId"
- line 46 : another "});" is missing

You should correct it ...
0 Kudos
GaneshSolai_Sambandam
New Contributor III
Hi Alex

There were missing brackets and semicolons and webmapid variable wasn't properly referenced with arcgisUtils function and therefore wasn't working properly. I have corrected them and it works fine. Use the code below.


var map,
        webmapId = "1a40fa5cc1ab4569b79f45444d728067";
    
    require([
      "esri/map",
      "esri/arcgis/utils",
      "esri/dijit/Legend",
      "dojo/domReady!"
      ], function (Map, arcgisUtils, Legend) {
        arcgisUtils.createMap(webmapId, "mapDiv").then(function (response) {
        map = response.map ; 
        
         var legend = new Legend({
            map: map,
            layerInfos:(arcgisUtils.getLegendLayers(response))
        }, "legendDiv");
        
        legend.startup();
        });

       
    });


Make sure you, reply saying this thread is answered.
0 Kudos
PhuongNguyen_Thanh
New Contributor
I'm trying the second basic tutorial : https://developers.arcgis.com/en/javascript/jstutorials/intro_agstemplate_amd.html
The code doesn't work, even in the sandbox : http://developers.arcgis.com/en/javascript/sandbox/sandbox.html?sample=map_webmap (map is blank)

I've tested it with IE9 and FF24 ; same results !

Where is the problem ? Sample codes aren't right ?

Thanks for your help.
Alex.

<!DOCTYPE html>
  <html>
  <head>
  <title>Create a Web Map</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <link rel="stylesheet" type="text/css" href="http://js.arcgis.com/3.7/js/esri/css/esri.css">
  <style>
    html,body,#mapDiv,.map.container{
      padding:0;
      margin:0;
      height:100%;
    }
    #legendDiv{
      background-color: #fff;
      position: absolute !important;
      z-index: 99;
      top:10px;
      right:20px;
    }
  </style>

  <script>var dojoConfig = { parseOnLoad:true };</script>
  <script src="http://js.arcgis.com/3.7compact/"></script>
  <script>
    var map,
        webmapId = "1a40fa5cc1ab4569b79f45444d728067";
    
    require([
      "esri/map",
      "esri/arcgis/utils",
      "esri/dijit/Legend",
      "dojo/domReady!"
      ], function (Map, arcgisUtils, Legend) {
        arcgisUtils.createMap(webmapId, "mapDiv").then(function (response) {
        map = response.map;     

        var legend = new Legend({
            map: map,
            layerInfos:(arcgisUtils.getLegendLayers(response))
        }, "legendDiv");
        
        legend.startup();
    });
      });
      
  </script>

  </head>

  <body>
    <div id="mapDiv"></div>
    <div id="legendDiv"></div>
  </body>
  </html>


Check this 😄
0 Kudos
JonathanUihlein
Esri Regular Contributor
I believe the sandbox is currently broken (It was a few days ago, for sure).

However, it looks like you've found the solution to your problem already; awesome!
0 Kudos
AlexandreECUVILLON1
New Contributor III
Thank you very much. The post is answered !
0 Kudos