Needed help on using own map service

728
7
06-11-2010 12:22 AM
PRamachandran
New Contributor
Hi,

I'm new to develope ArcGIS webmapping application using ArcGIS JAvascript APIs. I tried using the sample available at the resource site using Javascript API.

It worked sucessfully using the mapservice from ArcGisOnline as refered in the sample. Later I tried to use my own mapservice by creating a mapservice using the 'Publish Map service' option from the ArcGIS Manager.

I tried to replace the URL of the the newly published Mapservice with the existing one in the sample code as given below:



myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer

           ("http://srvnamexyz/ArcGIS1/rest/services/BaseMapping/MapServer");/// Note: 'BaseMapping' is the name of the map service which is newly added

///("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer");

            myMap.addLayer(myTiledMapServiceLayer); ///layer is added to a map
        }



Then I tried to run the same application with this modification, but it resulted in displaying a blank map window.

Please kindly help me on how to use my own mapservice while developing web application using ArcGIS Javascript APIs, your help is appreciated.



Thanks in advance.

Ram
0 Kudos
7 Replies
AdamPfister
Esri Contributor
Try to post a code sample that is as complete as possible using the CODE tags:
var sample = 'nicely formatted code';


if you type your map service URL with "?f=psjon" at the end into a browser: http://srvnamexyz/ArcGIS1/rest/services/BaseMapping/MapServer?f=psjon  do you get anything back?  if yes, what is it?  if an error, what is the error message?
0 Kudos
PRamachandran
New Contributor
I get an error stating :-

Error
Unsupported format 'psjon'

Code: 400



Can you please kindly suggest further on this regards?

Thanks,

Ram
0 Kudos
AdamPfister
Esri Contributor
that should be "pjson".  sorry about that.
0 Kudos
PRamachandran
New Contributor
{
  "serviceDescription" : "",
  "mapName" : "Layers",
  "description" : "",
  "copyrightText" : "",
  "layers" : [
    {
      "id" : 0,
      "name" : "UK_County_Boundaries",
      "parentLayerId" : -1,
      "defaultVisibility" : true,
      "subLayerIds" : null
    }
  ],
  "spatialReference" : {
    "wkid" : 27700
  },
  "singleFusedMapCache" : false,
  "initialExtent" : {
    "xmin" : -26869.8499046635,
    "ymin" : -55535.3854060575,
    "xmax" : 688396.489249775,
    "ymax" : 1281080.785195,
    "spatialReference" : {
      "wkid" : 27700
    }
  },
  "fullExtent" : {
    "xmin" : -26869.8499046635,
    "ymin" : -55535.3854060575,
    "xmax" : 688396.489249775,
    "ymax" : 1281080.785195,
    "spatialReference" : {
      "wkid" : 27700
    }
  },
  "units" : "esriMeters",
  "supportedImageFormatTypes" : "PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,AI",
  "documentInfo" : {
    "Title" : "BaseMapping",
    "Author" : "wall6694",
    "Comments" : "",
    "Subject" : "",
    "Category" : "",
    "Keywords" : ""
  }
}


I get the above result on following your suggestion.

please kindly further guide me to resolve.

Thanks,
Ram
0 Kudos
PRamachandran
New Contributor
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html id="Html1" runat="server" xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head id="Head1" runat="server">
    <title>Web Mapping Application using Javascript API</title>
 <link href='https://community.esri.com/ArcGIS1/rest/ESRI.ArcGIS.Rest.css' rel='stylesheet' type='text/css' />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dijit/themes/tundra/tundra.css" />
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6"></script>

    <script type="text/javascript">
        dojo.require("esri.map"); ///The script references the location of the ArcGIS Server JavaScript API files and the "map" package is referenced 
                                  ///Note that the version number needs to be updated to the current version of the JavaScript API.

        var myMap;
        var myTiledMapServiceLayer;
        function init() {
        
            myMap = new esri.Map("mapDiv");

            myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://din201009/ArcGIS1/rest/services/BaseMapping/MapServer");
           
            myMap.addLayer(myTiledMapServiceLayer); ///layer is added to a map
        }

        dojo.addOnLoad(init); ///Onload event
    </script>

   <%--  For LTR. . . use these styles if dir="ltr" in html tag    --%> 
   <style type="text/css">
        .appFloat1 {float: left;} 
        .appFloat2 {float: right;}
        .appAlign1 {text-align: left;}
        .appAlign2 {text-align: right;}
        .combined1 {float: left; text-align: left;}
        .combined2 {float: right; text-align: right;}
        .mapPosition {left: 260px; visibility: visible;} 
        .dockPosition {left: 0px; visibility: visible;} 
        .dockToggleClass {visibility: visible;}
        .offview {top: 1600px;}
   </style>
    
</head>
<body style="margin: 0px 0px 0px 0px; background-color: white;  width: 100%; font-family: Verdana; font-size:8pt; " >
<div id="mapDiv" class="tundra" style="width:900px; height:600px; border:1px solid #000;"></div>
    <h4>Work flow:</h4>
 <ul>
 <li>Create a map.</li>
 <li>Add an ArcGISTiledMapServiceLayer.</li>
 </ul>

    <form id="form1" runat="server">
</form>

 <%--  <script language="javascript" type="text/javascript">
    Sys.Application.add_init(startUp);
    </script> --%>

</body>
</html>



I've pasted the full code with which I'm currently working for your reference.
I hope it would be helpful to you to correct me If I'm wrong.
0 Kudos
AdamPfister
Esri Contributor
are you sure your layer you are trying to view is a Cached/Tiled layer?  it looks like it may be a dynamic layer from the json description you posted.
0 Kudos
PRamachandran
New Contributor
Thanks for the hint. I changed :
myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer

to

myTiledMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer


Its working fine.

Thanks a lot! once gain 🙂
0 Kudos