Problem with example

852
7
10-20-2010 05:24 AM
DanielTuracek
New Contributor
Hi I would like to ask on something what make me sad for this day. I spent maybe 5 hours looking for reason why this code doesnt work.
Im newbie in Javascript for API ,so i dont know why it doenst work. I try use example code with my URL for my service and it doesnt work.
With normal example it works great.
Can anzbody help me?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>Create Map</title>
    <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");

        function init() {
            var map = new esri.Map("map");

            var imageParameters = new esri.layers.ImageParameters();
            imageParameters.format = "JPEG";  //set the image type to JPEG, note default is PNG8.
            //Takes a URL to a non cached map service.
            var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://serverapp:8399/arcgis/services/HranicaSR2/MapServer", { "opacity": 0.5, "imageParameters": imageParameters });
            map.addLayer(dynamicMapServiceLayer);
        }

        dojo.addOnLoad(init);
    </script>
  </head>
  <body class="tundra">
    <div id="map" style="width:900px; height:600px; border:1px solid #000;"></div>
    Creates a map and adds an ArcGISDynamicMapServiceLayer.<br />
    Map navigation using mouse:
    <ul>
      <li>Drag to pan</li>
      <li>SHIFT + Click to recenter</li>
      <li>SHIFT + Drag to zoom in</li>
      <li>SHIFT + CTRL + Drag to zoom out</li>
      <li>Mouse Scroll Forward to zoom in</li>
      <li>Mouse Scroll Backward to zoom out</li>
      <li>Use Arrow keys to pan</li>
      <li>+ key to zoom in a level</li>
      <li>- key to zoom out a level</li>
      <li>Double Click to Center and Zoom in</li>
    </ul>
  </body>
</html>
0 Kudos
7 Replies
nicogis
MVP Frequent Contributor
0 Kudos
DanielTuracek
New Contributor
i give you know tomorow , because its our local test arcgis server, so i havent connection now.
There is probably problem with my service, i tried to get my service on display with more codes wich works fine for Arcgis example servers, but for my service i get just blank page.
I tried service for tiled map and dynamic too. i tried to import coordinate system from example files. but still nothing

thank you
and tomorow i will tell you more
0 Kudos
DanielYim
New Contributor II
First off, I want to mention that your code would've been easier to read and analyze with the forum's
 tags instead of what you used.

Anyway, one glaring problem that I see is that you're using the ArcGIS JS API version 1.6. This may be a deliberate choice of yours, but there is a much newer and better version out (v2.1). If you have mistakingly been using 1.6, then change 
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6"></script>
to
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script> 

and also change the external CSS from
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dijit/themes/tundra/tundra.css">

to
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css">


Other than that, I don't see why it shouldn't work. You should definitely look into ciava.at's suggestion, as I also think your use of custom imageParameters (set to JPEG) is why it's not rendering.

Good luck!
0 Kudos
AxelSchaefer
New Contributor II
You code is OK, your URL is wrong. You're not accessing the rest endpoint of your service.

Your URL is:
http://serverapp:8399/arcgis/services/HranicaSR2/MapServer


Should be something like:
http://serverapp:8399/arcgis/rest/services/HranicaSR2/MapServer
0 Kudos
DanielTuracek
New Contributor
Ok
I tried everything but no result.
Its seems like our rest doesnt work right way, because i copy the URL links directly from service manager, and there is no any rest middle of URL.
So i dont know.
0 Kudos
AxelSchaefer
New Contributor II
javanse_jongense,

ArcGIS Server supports per default - and beside others - two standard interfaces for every service: SOAP and REST. While the Service Manager and all of the Web-ADF, as the ArcGIS Desktop apps, consume ArcGIS Server services over SOAP, the Web-API like JS, Silverlight, Flex consume the AGS Services over REST.

The difference between the URLs to the services is the rest part, as I have said before.

Please take a look at the documentation of the JS API: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/ags_overview.htm

Especially take a look at your Services Directory at: http://serverapp:8399/arcgis/rest/ or any other service directory like The ArcGIS Online Services Directory.

Hope that helps.
0 Kudos
DanielTuracek
New Contributor
Ok i Got it 🙂

Now its everything working perfectly.
I dont know where i made mistake but it seems to be OK now.
Shame on me...
Thanks for everybody.
I can start learning JAVASCRIPT API 🙂
0 Kudos