Problem With ArcGIS Server Services

364
1
04-07-2011 01:21 AM
ZeeshanKhan
New Contributor
Hi,

I am new to  web mapping application with ArcGIS Java Script API, I build a page its works fine on Local, but when i go over internet, it doesn't show my Layers only Google Background image, I am giving my Live IP address to connect Services, These services can be viewed but i am not able to access these services through Web Application.

I am pasting my code below.
________________________________________________________________________________

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  <head>
    <title>ArcGIS</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>

    <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAoCCuxJYvQKuOME9a3Fc8KhS3iegp0cxLQXAJedXkaj3wQFF..." type="text/javascript"></script>
    <script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.6" type="text/javascript" ></script>

    <script type="text/javascript">

    var gmap = null;

    function initialize() {
      gmap = new GMap2(document.getElementById("gmap"));
      var centerat = new GLatLng(31.592, 71.014);

      gmap.addControl(new GLargeMapControl());
      gmap.addControl(new GMapTypeControl());
      gmap.setCenter(centerat, 6);


      var admin = new esri.arcgis.gmaps.DynamicMapServiceLayer
        ("http://0.0.0.0(myliveip)/ArcGIS/rest/services/javatest/admin_boundries/MapServer",
        null, 0.75, dynmapcallback);
  }
    function dynmapcallback(mapservicelayer) {
      gmap.addOverlay(mapservicelayer);
    }
    </script>
  </head>
  <body onload="initialize();" onunload="GUnload();">
    <div id="gmap" style="width: 100%; height:550px;"></div>
  </body>
</html>
0 Kudos
1 Reply
SiqiLi
by Esri Contributor
Esri Contributor
1.Please add the reference of ArcGIS API for JavaScript into HTML HEAD element of your HTML page
  e.g.  <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.2"></script>

2. Please create a map variable using esri.Map class. Specify value "gmap" as the name of the DIV element that will contain the map.
   e.g.   var map = new esri.Map("gmap");

3. Please create a mapservicelayer variable using using the ArcGISDynamicMapServiceLayer constructor.
   e.g. var mapservicelayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://<server name>/ArcGIS/rest/services/javatest/admin_boundries/MapServer",{"opacity":0.75});

4. Add the mapservicelayer to the map using the map's addLayer method
   e.g. map.addLayer(mapservicelayer);




-------Here is the revised code------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<title>ArcGIS</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAoCCuxJYvQKuOME9a3Fc8KhS3iegp0cxLQXAJedXkaj3wQFF..." type="text/javascript"></script>
<script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.6" type="text/javascript" ></script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.2"></script>

<script type="text/javascript">
function initialize() {
  var gmap = new GMap2(document.getElementById("gmap"));
  var centerat = new GLatLng(31.592, 71.014);
  gmap.addControl(new GLargeMapControl());
  gmap.addControl(new GMapTypeControl());
  gmap.setCenter(centerat, 6);

  var map = new esri.Map("gmap");
  var mapservicelayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://0.0.0.0(myliveip)/ArcGIS/rest/services/javatest/admin_boundries/MapServer",{"opacity":0.75});
  map.addLayer(mapservicelayer);
}
</script>
</head>

<body onload="initialize();" onunload="GUnload();">
   <div id="gmap" style="width: 100%; height:550px;"></div>
</body>
</html>
0 Kudos