0

I started following the code sample the Esri provided, but when I run it the map doesn't show up.

This is the link: https://developers.arcgis.com/javascript/latest/sample-code/get-started-mapview/index.html

This is the code:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Get started with MapView - Create a 2D map</title>
<style>
  html, body, #viewDiv {
    padding: 0;
    margin: 0;
    height: 100%;
    width: 100%;
  }
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.1/esri/css/main.css">
<script src="https://js.arcgis.com/4.1/"></script>
<script>
require([
  "esri/Map",
  "esri/views/MapView",
  "dojo/domReady!"
], function(Map, MapView){
  var map = new Map({
    basemap: "local"
  });
  var view = new MapView({
    container: "viewDiv",  // Reference to the scene div created in step 5
    map: map,  // Reference to the map object created before the scene
    zoom: 4,  // Sets the zoom level based on level of detail (LOD)
    center: [15, 65]  // Sets the center point of view in lon/lat
  });
});
</script>
</head>
<body>
  <div id="viewDiv"></div>
</body>
</html>

1 Answer 1

1

Are you running it off your local machine? Images will not load if you are loading the file via its directory on the machine... e.g. typing C:\Code\map.html into the address bar.

You will need to host the file using a simple web server (python, apache, iis) so that the requests for map tiles are made over http. You can then access your working map through http://localhost:8080/map.html or however you want to set it up.

2
  • I tried web server tomcate, stil the same probelm Oct 5, 2016 at 8:17
  • What does the debugging console in your web browser say? Also, try viewing the network responses and resources for the web tiles. Is NOTHING show up? Is the UI there?
    – Thomas
    Oct 5, 2016 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.