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>
nmtoken
13.6k5 gold badges39 silver badges91 bronze badges
asked Oct 3, 2016 at 20:37

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.

answered Oct 4, 2016 at 15:25
2
  • I tried web server tomcate, stil the same probelm Commented 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? Commented Oct 5, 2016 at 17:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.