So I've just finished the tutorial to at least get a map on the screen, and it already isn't working. Can someone see what I'm missing?htmlfilejavascriptfile
-
1how are you accessing your webmap? Are you just calling the C:\\path\to\app?Craig– Craig2014年03月08日 00:49:51 +00:00Commented Mar 8, 2014 at 0:49
-
1I think you should edit your Question to include a link to the tutorial you are working through and use the Code formatting button to include the text (rather than image) of your code.PolyGeo– PolyGeo ♦2014年03月08日 01:32:50 +00:00Commented Mar 8, 2014 at 1:32
-
Here is a link to the tutorial. I don't have a web server yet, I need to design it before it goes online.ottesen07– ottesen072014年03月10日 22:33:32 +00:00Commented Mar 10, 2014 at 22:33
2 Answers 2
attempting to load an external .js file in a script tag via file protocol is a problem
<script src="C:\Users\mottesen\Documents\Visual Studio 2013\Projects\SF_IM\SF_IM\My Project\SF_IM.js"></script>
try using either an http path or a relative path instead.
additionally, as noted in the help, loading your own application in the browser via http (as opposed to using file protocol) is mandatory as well.
https://developers.arcgis.com/javascript/jshelp/intro_devenv.html
You should probably scrap your local .js file, as John pointed out. Just write the code in the main HTML file. Since you're just starting out, you should try to get used to writing in the new AMD style since you're using the 3.8 API.
<script>
var map;
require(["esri/map", "dojo/parser", "dojo/domReady!"],
function(esriMap, parser) {
parser.parse();
map = new esriMap("mapDiv", {
center: [56.049, 38.485],
zoom: 3,
basemap: "streets"
});
}
);
</script>
-
Is putting
map
in the global namespace really necessary?blah238– blah2382014年03月14日 21:26:35 +00:00Commented Mar 14, 2014 at 21:26 -
Probably not, but just about every ESRI sample does it.Mintx– Mintx2014年03月14日 21:37:18 +00:00Commented Mar 14, 2014 at 21:37
-
@blah238 I put the map in the global namespace because I then do not need to define it in everyone of my widgets.Jeremy Hamm– Jeremy Hamm2014年03月17日 14:32:29 +00:00Commented Mar 17, 2014 at 14:32