beginner's question on Javascript API

3401
8
Jump to solution
02-05-2015 06:35 AM
DanielSchatt
New Contributor III

hi all, I'm trying to set up my very first web page using the Javascript API.  Just copied and pasted the code from ESRI's "Build your first application" into a text editor, saved it as an .htm document (careful NOT to have a .txt suffix), and put in on my web server.  But when I open that .htm file in my browser as a URL, it just displays the plain text of the code in the .htm file.  It's not showing the map or reading/interpreting the HTML and Javascript code to get that content.  So what am I missing here?  Thanks for any help.

Dan

0 Kudos
1 Solution

Accepted Solutions
ChrisSergent
Regular Contributor III

Here is exactly how you do it. I recorded my screen and explained it in this video:

View solution in original post

8 Replies
ChrisSergent
Regular Contributor III

Can you share the code you wrote? Also besides the suffix you should save file as type to all files. Some text editors default to text document and you don't want that.

0 Kudos
DanielSchatt
New Contributor III

thanks Chris.  Here it is:

<!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.12/dijit/themes/claro/claro.css">

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

  <style>

    html, body, #mapDiv{

      padding: 0;

      margin: 0;

      height: 100%;

    }

  </style>

 

  <script src="http://js.arcgis.com/3.12/"></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>

0 Kudos
ChrisSergent
Regular Contributor III

Here is exactly how you do it. I recorded my screen and explained it in this video:

DanielSchatt
New Contributor III

thanks Chris and everyone, got it!

Venkata_RaoTammineni
Occasional Contributor

Can you please share your code..

probable issues..

1. is your JS files are in right path ?

2. is your REST end point correct ?

Thanks,

Venkat

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Hi Dan,

Can you upload the htm file, or copy/paste the code you used?  If you copy/paste, take a look at this post on how to do so in GeoNET:

Posting Code blocks in the new GeoNet

0 Kudos
ChrisSergent
Regular Contributor III

I had no problems with your code. Are you opening it with a browser?

0 Kudos
DanielSchatt
New Contributor III

yes, in both Firefox and IE.  I assumed maybe I was leaving out some basic step, but apparently not...might be some setting I need to change in my browser?

0 Kudos