Select to view content in your preferred language

Getting Started

9993
30
Jump to solution
01-18-2014 05:24 AM
jaykapalczynski
Honored Contributor
I am running through some tutorials and having an issue

https://developers.arcgis.com/en/javascript/jstutorials/intro_agstemplate_amd.html

I am trying to use the Web Map Id they said you can in the example and then the map vanishes.  I dont know how to get another one I can use.
I assume that the web map id is not working....what else can I be doing wrong
If you haven't created a web map yet, you can use 1a40fa5cc1ab4569b79f45444d728067 for testing.


require([       "esri/map",       "esri/arcgis/utils",       "dojo/domReady!"       ], function(Map, arcgisUtils){       arcgisUtils.createMap("1a40fa5cc1ab4569b79f45444d728067", "mapDiv").then(function (response) {           map = response.map;          });   });


If I use this from the first example then the map shows up fine

map = new Map("mapDiv", { center: [-77.4329, 37.5410], zoom: 6, basemap: "streets"



<script>   var map;     require(["esri/map", "esri/arcgis/utils", "esri/dijit/Legend", "dojo/domReady!"     ], function(Map, arcgisUtils, Legend ) {          arcgisUtils.createMap("1a40fa5cc1ab4569b79f45444d728067", "mapDiv").then(function (response) {    map = response.map;           var legend = new Legend({       map: map,        layerInfos:(arcgisUtils.getLegendLayers(response))     }, "legendDiv");          legend.startup();         });         }); </script>
0 Kudos
30 Replies
jaykapalczynski
Honored Contributor
Got it Jon...thanks
tried Localhost and it defaulted to an html page inside the folder...
but went into the Default Document in IIS and that specific html page was top of the list in the defaults
Also noticed that the two websites I created all were using the default port 80....
I changed the ports to 81 and 82 and then did a localhost:81 and the file set for default displayed...
I then did localhost:81/webmapping.html and the page came up fine...

Maps and the geocoder examples are working from the examples the way they should....I think I am good to go....

Thank you all for your thoughts and comments throughout this post.....VERY appreciated.
0 Kudos
JonathanUihlein
Esri Regular Contributor
Great! Glad everything is working.

Make sure you mark this thread as answered (using one of Roberto's posts).

Thanks!!
0 Kudos
by Anonymous User
Not applicable
Here is the solution:

http://forums.arcgis.com/threads/83941-ArcGIS-Online-Map-using-URL-does-not-work-with-PhoneGap-2.7


esri.arcgis.utils.arcgisUrl = esri.arcgis.utils.arcgisUrl.replace("file:", "http:");
0 Kudos
HugoSelbie
Deactivated User
I have this code which works in JS fiddle (copied and pasted map id into previous fiddle from the thread. However when I copy and paste this exact code into a text editor saved as a .html file. I get an error message in firebug and chrome developer tools saying.

OPTIONS file://www.arcgis.com/sharing/rest/content/items/020ee0f8315e42c1b01047a2ae75265e?f=json net::ERR_FILE_NOT_FOUND

Any ideas why this is and how to fix?

<!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.8/js/esri/css/esri.css">
    <style>
        html,
        body,
        #mapDiv,
        .map.container {
            padding: 0;
            margin: 0;
            height: 100%;
        }
    </style>

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

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

</html>
0 Kudos
JonathanUihlein
Esri Regular Contributor
Are you accessing your application from a web-server?
0 Kudos
HugoSelbie
Deactivated User
I'm just opening the file through a browser, chrome and firefox.
0 Kudos
JonathanUihlein
Esri Regular Contributor
That's the source of your problem.

You need to make sure you have a web-server running (IIS, apache etc) and that your application (html file) is in the correct directory.
0 Kudos
HugoSelbie
Deactivated User
Thanks very much for your help, is there anyway to display webmaps without a webserver running?
0 Kudos
JonathanUihlein
Esri Regular Contributor
Thanks very much for your help, is there anyway to display webmaps without a webserver running?


Websites generally need a webserver. There are many reasons why (communication, security, etc... many blog posts and wiki articles about the technical details).

If you absolutely cannot install a local webserver, you will probably have to use something like jsfiddle.

Some computers ship with a webserver by default so you might want to check if you have one installed already.
0 Kudos
jaykapalczynski
Honored Contributor
You may also simply need to activate/turn on IIS...our installs had it turned off.....but then again thats an IT policy thing on your end.  There are free options as well...

Free local installs:  https://www.apachefriends.org/index.html   (Web Server, PHP, MySQL db)

Free options for Hosting:  http://www.prchecker.info/web-hosting/top-10-free-web-hosting-sites/
0 Kudos