Select to view content in your preferred language

Getting Started

9987
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
RobertoPepato
Deactivated User
Yea I tried your example EXACTLY....it works in Fiddle but not when I placed it in my IIS website.  Could there be something in IIS thats not letting me get there?
I used the map ID that you did in your Fiddle examples....that should work right?  Does not on my side

Am I not getting the correct ID to you?  Where exactly do I get it from....after I open it from within ArcGIS online org account?  When I try those ids I dont even get to where you are asking for a login

Do I have to have an editable Feature in the web map?  It should work with simply the basemap right>
Yes I shared it
[ATTACH=CONFIG]30619[/ATTACH]

Do you have an ID that works that I can test in my html code?
I have not idea whats going on....

This is my Whole page....all the code I am using

<!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("1a40fa5cc1ab4569b79f45444d728067", "mapDiv").then(function (response) {
          map = response.map;   
      });
  });
    
  </script>
  </head>

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


It looks like there is something on your environment making the sample behave this way.

Let me explain what I did here now:

Until this message, I was trying the sample using Safari/Chrome browser and publishing the pages on a Apache WebServer.

After you last message, I started suspecting that the problem should be in IIS. So, I started a Windows 7 on a virtual machine and deploy your code on IIS. And it worked on every browser I tested (chrome/firefox/IE). I've also copied your code to a new JSFiddle and it also worked:

http://jsfiddle.net/rpepato/qQDzj/

On a previous message you've posted a log from your application with the following content (among other things):

Unable to load file
file://www.arcgis.com/sharing/rest/�?�7f843bb0a37849f68a5a2cc3d2b06288?f=json

Can you access the url www.arcgis.com/sharing/rest/�?�7f843bb0a37849f68a5a2cc3d2b06288?f=json . Can you see a Json document returned?

Could your post some information about your environmento (OS model and version, browser and version, etc)?
0 Kudos
jaykapalczynski
Honored Contributor
I can access that new Fiddle you created fine

I am trying to access that URL when I click it I get this in the browsers URL
http://www.arcgis.com/sharing/rest/%E2%80%A67f843bb0a37849f68a5a2cc3d2b06288?f=json

When I navigate there I get this error
{"error":{"code":400,"messageCode":"GWM_0002","message":"Invalid URL","details":[]}}


click to see image:  [ATTACH=CONFIG]30620[/ATTACH]

Note I am using my Laptop and WiFi...just local
I am running Win8 64 Bit using Chrome Version 32.0.1700.76 m
Using IIS Version 8.09200.16384
I simply activated IIS on my computer....Maybe because I dont have win8 professional or something that IIS is not the correct version?  Win8 I have allowed my to go in and turn on IIS so I assume that it shoudl work.


THIS WORKS:
  <script>
  var map;
    require(["esri/map", "dojo/domReady!"
    ], function(Map) { 

   map = new Map("mapDiv", {
     center: [-77.4329, 37.5410],
     zoom: 6,
     basemap: "streets"
   
   });
   
    });
  </script>



THIS DOES NOT:
 
  <script>
    require([
      "esri/map",
      "esri/arcgis/utils",
      "dojo/domReady!"
      ], function(Map, arcgisUtils){
      arcgisUtils.createMap("1a40fa5cc1ab4569b79f45444d728067", "mapDiv").then(function (response) {
          map = response.map;   
      });
  });
    
  </script>
0 Kudos
RobertoPepato
Deactivated User
I don't know why the url gets truncated on my latest post but the correct one is:

www.arcgis.com/sharing/rest/content/items/7f843bb0a37849f68a5a2cc3d2b06288?f=json


Can you access successfully?
0 Kudos
jaykapalczynski
Honored Contributor
I don't know why the url gets truncated on my latest post but the correct one is:

www.arcgis.com/sharing/rest/content/items/7f843bb0a37849f68a5a2cc3d2b06288?f=json


Can you access successfully?



If I cut and paste into URL I get this

{"id" : "7f843bb0a37849f68a5a2cc3d2b06288","owner" : "jay.kapalczynski","created" : 1390042038000,"modified" : 1390069539000,"guid" : null,"name" : null,"title" : "TESTING","type" : "Web Map","typeKeywords" : ["ArcGIS Online", "Explorer Web Map", "Map", "Online Map", "Web Map"],"description" : null,"tags" : ["TESTING", "JAYSTESTING"],"snippet" : null,"thumbnail" : "thumbnail/ago_downloaded.png","documentation" : null,"extent" : [[-83.0815, 33.6994], [-75.4131, 41.156]],"spatialReference" : null,"accessInformation" : null,"licenseInfo" : null,"culture" : "en-us","properties" : null,"url" : null,"access" : "public","size" : 446,"appCategories" : [],"industries" : [],"languages" : [],"largeThumbnail" : null,"banner" : null,"screenshots" : [],"listed" : false,"commentsEnabled" : true,"numComments" : 0,"numRatings" : 0,"avgRating" : 0.0,"numViews" : 26}
0 Kudos
jaykapalczynski
Honored Contributor
i can get to it from your URL but when I run from here.....as seen below code....I get this in the console error on WebMap

It has to be something with IIS....maybe the IIS that comes with Win8 is not able to get out or wont get to that URL???
I am lost here...
Tried the Geocoder example from API examples and it just spins endlessly when I submit an address.

I get this error with the Geocoder Example
ERROR Geocoder example  https://developers.arcgis.com/en/javascript/jssamples/locator_simple.html
MLHttpRequest cannot load http://services.arcgisonline.com/ArcGIS/rest/info?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.


ERROR FOR WebMap:
OPTIONS file://www.arcgis.com/sharing/rest/content/items/7f843bb0a37849f68a5a2cc3d2b06288?f=json  init.js:158
r {stack: "Error: Unable to load file://www.arcgis.com/sharin�?�uest.h (http://js.arcgis.com/3.8/init.js:160:167)", message: "Unable to load file://www.arcgis.com/sharing/rest/�?�7f843bb0a37849f68a5a2cc3d2b06288?f=json status: 0", response: Object, status: 0, responseText: ""�?�}
_ssl: undefined
log: undefined
message: "Unable to load file://www.arcgis.com/sharing/rest/content/items/7f843bb0a37849f68a5a2cc3d2b06288?f=json status: 0"
response: Object
responseText: ""
stack: "Error: Unable to load file://www.arcgis.com/sharing/rest/content/items/7f843bb0a37849f68a5a2cc3d2b06288?f=json status: 0�?�    at Error (native)�?�    at new r (http://js.arcgis.com/3.8/init.js:221:367)�?�    at XMLHttpRequest.h (http://js.arcgis.com/3.8/init.js:160:167)"
status: 0
xhr: XMLHttpRequest
__proto__: a


  <script>
    require([
      "esri/map",
      "esri/arcgis/utils",
      "dojo/domReady!"
      ], function(Map, arcgisUtils){
      arcgisUtils.createMap("7f843bb0a37849f68a5a2cc3d2b06288", "mapDiv").then(function (response) {
          map = response.map;   
      });
  });
    
  </script>
0 Kudos
RobertoPepato
Deactivated User
i can get to it from your URL but when I run from here.....as seen below code....I get this in the console error on WebMap

It has to be something with IIS....maybe the IIS that comes with Win8 is not able to get out or wont get to that URL???
I am lost here...
Tried the Geocoder example from API examples and it just spins endlessly when I submit an address.

I get this error with the Geocoder Example
ERROR Geocoder example  https://developers.arcgis.com/en/javascript/jssamples/locator_simple.html
MLHttpRequest cannot load http://services.arcgisonline.com/ArcGIS/rest/info?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.


ERROR FOR WebMap:
OPTIONS file://www.arcgis.com/sharing/rest/content/items/7f843bb0a37849f68a5a2cc3d2b06288?f=json  init.js:158
r {stack: "Error: Unable to load file://www.arcgis.com/sharin???uest.h (http://js.arcgis.com/3.8/init.js:160:167)", message: "Unable to load file://www.arcgis.com/sharing/rest/???7f843bb0a37849f68a5a2cc3d2b06288?f=json status: 0", response: Object, status: 0, responseText: ""???}
_ssl: undefined
log: undefined
message: "Unable to load file://www.arcgis.com/sharing/rest/content/items/7f843bb0a37849f68a5a2cc3d2b06288?f=json status: 0"
response: Object
responseText: ""
stack: "Error: Unable to load file://www.arcgis.com/sharing/rest/content/items/7f843bb0a37849f68a5a2cc3d2b06288?f=json status: 0???    at Error (native)???    at new r (http://js.arcgis.com/3.8/init.js:221:367)???    at XMLHttpRequest.h (http://js.arcgis.com/3.8/init.js:160:167)"
status: 0
xhr: XMLHttpRequest
__proto__: a


  <script>     require([       "esri/map",       "esri/arcgis/utils",       "dojo/domReady!"       ], function(Map, arcgisUtils){       arcgisUtils.createMap("7f843bb0a37849f68a5a2cc3d2b06288", "mapDiv").then(function (response) {           map = response.map;          });   });        </script>


Do you have a skype (or any other IM) account? Let's try to figure it out via an IM conversation?
0 Kudos
JonathanUihlein
Esri Regular Contributor
@Roberto: Thanks for all your help so far!

@jay: This may seem like a silly question but I need to ask:
How are you attempting to view your application?

Correct (example paths):
localhost/test/forum/test.html

http://jontest.test.com/test/forum/test.html


Incorrect:
file:///C:/inetpub/wwwroot/test/forum/test.html


Some users do not realize they need to view their application in the context of a webserver, and instead try to open the file directly using their browser.
0 Kudos
jaykapalczynski
Honored Contributor
Tell you the truth I dont remember....I cannot test right now but will do so later...Thanks for your suggestion.
Cheers.
0 Kudos
jaykapalczynski
Honored Contributor
trying to get there with this:

get the error see attached.....maybe because I dont have win8 pro IIS is not running as a server?  I dont know
thoughts

[ATTACH=CONFIG]30679[/ATTACH]

http://localhost/JavaScriptApplication/index.html

[ATTACH=CONFIG]30680[/ATTACH]
0 Kudos
JonathanUihlein
Esri Regular Contributor
Hi Jay!
Thanks so much for the response.

From your screenshots, its clear that the file is located in the correct directory.
Because of that, it definitely looks like an IIS configuration issue, (plus its returning 404 -- file not found).

Make sure localhost refers to 'C:\inetpub\wwwroot' (the default)
Has the webserver been turned on? (Check in IIS Manager)
What do you see when you go to 'localhost' in your browser? (You may or may not see a file listing).

Let me know what you find!
Jon
0 Kudos