Map Service not loading using Javascript API

810
3
01-28-2011 09:00 AM
VinayVyas
New Contributor
Hi,
I have a local ArcGIS server using which I published a service.
The service works using the "Create a Web Application" Wizard.

I downloaded a sample code and it ran smoothly, the difference is the URL is online and not local to my server.

I want to run this code using my local ArcGIS server URL and all I see is a blank screen. The map is error free. Can anybody help resolve this?

My code

<html>
<head>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1" type="text/javascript"></script>
<link href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css" rel="stylesheet" type="text/css" >
</head>
<script type="text/javascript">
  dojo.require("esri.map");
var map;'
function init()
{
map=new esri.Map("mapDiv")
var basemapURL = "http://8hXXXX:8399/arcgis/rest/services/Map_City/MapServer";
var basemap = new esri.layers.ArcGISDynamicMapServiceLayer(basemapURL);
map.addLayer(basemap);
  }
dojo.addOnLoad(init);

</script>
<body class="caro">
<div id="mapDiv" style="width:900px;height:600px;border:1px solid #000;"></div>
</body>
</body>
</html>

Thanks!

PS: URL no is censored for security
0 Kudos
3 Replies
HemingZhu
Occasional Contributor III
Hi,
I have a local ArcGIS server using which I published a service.
The service works using the "Create a Web Application" Wizard.

I downloaded a sample code and it ran smoothly, the difference is the URL is online and not local to my server.

I want to run this code using my local ArcGIS server URL and all I see is a blank screen. The map is error free. Can anybody help resolve this?

My code

<html>
<head>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1" type="text/javascript"></script>
<link href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css" rel="stylesheet" type="text/css" >
</head>
<script type="text/javascript">
  dojo.require("esri.map");
var map;'
function init()
{
map=new esri.Map("mapDiv")
var basemapURL = "http://8hXXXX:8399/arcgis/rest/services/Map_City/MapServer";
var basemap = new esri.layers.ArcGISDynamicMapServiceLayer(basemapURL);
map.addLayer(basemap);
  }
dojo.addOnLoad(init);

</script>
<body class="caro">
<div id="mapDiv" style="width:900px;height:600px;border:1px solid #000;"></div>
</body>
</body>
</html>

Thanks!

PS: URL no is censored for security


can you view your service in a browser using http://8hXXXX:8399/arcgis/rest/services/Map_City/MapServer?
0 Kudos
JohnHaddad
Esri Contributor
I can think of 3 possibilities:

1. Your service is cached and you are using the ArcGISDynamicMapServiceLayer directive which is for dynamic map services.

2. You are using a reverse proxy (I noticed that you are using a non-standard port) and it is not configured correctly. See http://resources.arcgis.com/content/kbase?fa=articleShow&d=32634 for more info.

3. I see a small typo in your code (space in the variable name 'basemapUR L'):


 {
 map=new esri.Map("mapDiv")
 var basemapURL = "http://8hXXXX:8399/arcgis/rest/services/Map_City/MapServer";
 var basemap = new esri.layers.ArcGISDynamicMapServiceLayer(basemapUR L);
 map.addLayer(basemap);
  }
0 Kudos
derekswingley1
Frequent Contributor
Also, the class attribute on the body tag should be "claro", not "caro".
0 Kudos