Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I created a Map Service in arc catalog.

Now How i can load this map with javascript api ?

I have this sample :

  <!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" />
            <meta name="viewport" content="width=device-width,user-scalable=no"/>
            <!--The viewport meta tag is used to improve the presentation and behavior of the samples 
              on iOS devices-->
            <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
            <title>Maps Toolbar</title>
            <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css">
            <style type="text/css">
              html, body {
                height: 100%; width: 100%; margin: 0; padding: 0;
              }
            </style>
            <script type="text/javascript">
              djConfig = {
                parseOnLoad: true
              }
            </script>
            <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script>
            <script type="text/javascript">
              dojo.require("esri.map");
              dojo.require("esri.toolbars.draw");
              dojo.require("dijit.dijit"); // optimize: load dijit layer
              dojo.require("dijit.layout.BorderContainer");
              dojo.require("dijit.layout.ContentPane");


              var map, toolbar, symbol, geomTask;
              function init() {



                var startExtent = new esri.geometry.Extent({"xmin":-11721159.665358918,"ymin":-1138850.8106919006,"xmax":8277212.918942982,"ymax":9858297.322750043,"spatialReference":{"wkid":102100}});
                map = new esri.Map("map",{extent:startExtent});
                dojo.connect(map, "onLoad", createToolbar);
                var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://mehdi-pc/arcgis/services/HasanAbad/MapServer");
                map.addLayer(basemap);
              }

              function createToolbar(map) {
                toolbar = new esri.toolbars.Draw(map);
                //set drawing mode to extent
                toolbar.activate(esri.toolbars.Draw.POINT);
                dojo.connect(toolbar, "onDrawEnd", addToMap);
              }

              function addToMap(geometry) {
              //toolbar.deactivate();

              alert(geometry.x);
              alert(geometry.y);

              map.graphics.clear();

              var symbol =  new esri.symbol.PictureMarkerSymbol({
"url":"http://images.rcuniverse.com/forum/thumbnails/504424/Hf97773.jpg",
"height":20,
"width":20,
"type":"esriPMS"
 });

              map.showZoomSlider();
               switch (geometry.type) {
                  case "point":
                    var symbol1 = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_Pushp , 50, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2), new dojo.Color([0,255,0,1]));

                }

                var graphic1 = new esri.Graphic(geometry, symbol);



                map.graphics.add(graphic1);

              }

              dojo.addOnLoad(init);
            </script>
          </head>
          <body class="claro">
        <div id="mainWindow" dojotype="dijit.layout.BorderContainer" design="headline" gutters="false" style="width:100%; height:100%;">


            <div id="map" dojoType="dijit.layout.ContentPane" style="border:solid 2px #587498;margin:5px;" region="center">
            </div>
        </div>
          </body>
        </html>

But this load map from esri.

I want load map from my map service.

share|improve this question

closed as unclear what you're asking by Stephen Lead, PolyGeo, Brad Nesom, Mapperz Jun 18 at 14:24

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

    
The links direct to arcgis servers, have you tried to change them? –  Andre Joost Jun 18 at 8:01

1 Answer 1

You are using an internal server so it's hard to tell, but I will assume you are not using a tiled map service. I would change this line from --

var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://mehdi-pc/arcgis/services/HasanAbad/MapServer");

to

var basemap = new esri.layers.ArcGISDynamicMapServiceLayer("http://mehdi-pc/arcgis/services/HasanAbad/MapServer");

FYI, if you are starting a new project you should use the latest jsapi 3.2

share|improve this answer
    
unfortunately this isn't work :( –  Mehdi Nov 17 '12 at 9:16
    
When i change that line and refresh page in browser, page was empty.:( –  Mehdi Nov 17 '12 at 9:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.