1

I have installed ArcGIS Server on my server, and have published a service called "background2". "background2" contains two layers: "passage3" (line layer) and "parcel_utm_rrr" (polygon). I have enabled WMS capability and have also created cache for the service.

The URL for the WMS is: http://myserver:6080/arcgis/services/background2/bacground2/MapServer/WMSServer

Now I want to use this address in OpenLayers and show the map. I have written something like this (script part):

var bounds = new OpenLayers.Bounds(
                573213.5564000001, 3216709.8500999995,
               661257.9056609625, 3283209.3853075416
            );
var options = {
            controls: [],
            maxExtent: bounds,
            maxResolution: 716.0066545168374,
            projection: "EPSG:3857",
            units: 'm'
        };
        map = new OpenLayers.Map('map', options);      
        layer = new OpenLayers.Layer.WMS("background2", "http://gis.shiraz.ir:6080/arcgis/services/background2/bacground2/MapServer/WMSServer", {
            layers: [
  {
      "id": 0,
      "name": "passage3"
  },
  {
      "id": 1,
      "name": "parcel_utm-rrr"
  }
            ],
            format: "image/png32"
        }, {
            isBaseLayer: true
        });
        map.addLayers([layer]);
        map.zoomToExtent(layer.getExtent());

But it does not work. I do not know what the problem is...

Note: the id and name for each layer came from the REST API (http://myserver:6080/arcgis/rest/services/background2/bacground2/MapServer) the following code is copied from above address:

    Service Description:

    Map Name: Layers

    Legend

    All Layers and Tables

    Layers:

    passage3 (0)
    parcel_utm-rrr (1)

    Description:

    Copyright Text:

    Spatial Reference: 102100  (3857)


    Single Fused Map Cache: true

    Tile Info:

    Height: 256
    Width: 256
    DPI: 96
    Levels of Detail: 20
        Level ID: 0 [ Start Tile, End Tile ]
            Resolution: 156543.03392800014
            Scale: 5.91657527591555E8
        Level ID: 1 [ Start Tile, End Tile ]
            Resolution: 78271.51696399994
            Scale: 2.95828763795777E8
        Level ID: 2 [ Start Tile, End Tile ]
            Resolution: 39135.75848200009
            Scale: 1.47914381897889E8
        Level ID: 3 [ Start Tile, End Tile ]
            Resolution: 19567.87924099992
            Scale: 7.3957190948944E7
        Level ID: 4 [ Start Tile, End Tile ]
            Resolution: 9783.93962049996
            Scale: 3.6978595474472E7
        Level ID: 5 [ Start Tile, End Tile ]
            Resolution: 4891.96981024998
            Scale: 1.8489297737236E7
        Level ID: 6 [ Start Tile, End Tile ]
            Resolution: 2445.98490512499
            Scale: 9244648.868618
        Level ID: 7 [ Start Tile, End Tile ]
            Resolution: 1222.992452562495
            Scale: 4622324.434309
        Level ID: 8 [ Start Tile, End Tile ]
            Resolution: 611.4962262813797
            Scale: 2311162.217155
        Level ID: 9 [ Start Tile, End Tile ]
            Resolution: 305.74811314055756
            Scale: 1155581.108577
        Level ID: 10 [ Start Tile, End Tile ]
            Resolution: 152.87405657041106
            Scale: 577790.554289
        Level ID: 11 [ Start Tile, End Tile ]
            Resolution: 76.43702828507324
            Scale: 288895.277144
        Level ID: 12 [ Start Tile, End Tile ]
            Resolution: 38.21851414253662
            Scale: 144447.638572
        Level ID: 13 [ Start Tile, End Tile ]
            Resolution: 19.10925707126831
            Scale: 72223.819286
        Level ID: 14 [ Start Tile, End Tile ]
            Resolution: 9.554628535634155
            Scale: 36111.909643
        Level ID: 15 [ Start Tile, End Tile ]
            Resolution: 4.77731426794937
            Scale: 18055.954822
        Level ID: 16 [ Start Tile, End Tile ]
            Resolution: 2.388657133974685
            Scale: 9027.977411
        Level ID: 17 [ Start Tile, End Tile ]
            Resolution: 1.1943285668550503
            Scale: 4513.988705
        Level ID: 18 [ Start Tile, End Tile ]
            Resolution: 0.5971642835598172
            Scale: 2256.994353
        Level ID: 19 [ Start Tile, End Tile ]
            Resolution: 0.29858214164761665
            Scale: 1128.497176
       Format: PNG
    Compression Quality: 0.0
    Origin: X: -2.0037508342787E7
    Y: 2.0037508342787E7
    Spatial Reference: 102100  (3857)

    Initial Extent:

    XMin: 643873.6028923569
    YMin: 3277777.8384444476
    XMax: 661257.9056609625
    YMax: 3283209.3853075416
    Spatial Reference: 102100

    Full Extent:

    XMin: 573213.5564000001
    YMin: 3216709.8500999995
    XMax: 730416.5669
    YMax: 3367589.826300001
    Spatial Reference: 102100

    Units: esriMeters

   Supported Image Format Types:           PNG32,PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,BMP

    Document Info:

    Title:
    Author:
    Comments:
    Subject:
    Category:
    Keywords:
    AntialiasingMode: None
    TextAntialiasingMode: Force

     Supports Dynamic Layers: false

     MaxRecordCount: 1000

      MaxImageHeight: 4096

        MaxImageWidth: 4096

       Supported Query Formats: JSON, AMF

Min Scale: 5.91657527591555E8

Max Scale: 1128.497176
  • Does the WMS service work outside of OpenLayers, for example if you make a GetCapabilities request in a browser like: myserver:6080/arcgis/services/background2/bacground2/MapServer/… – nmtoken Jan 9 '17 at 20:17
  • The general answer to your title question is of course yes, it shouldn't matter which server software is providing a WMS (as long as the service is correctly configured and working to the WMS standard), the OpenLayers API should be able to consume it. – nmtoken Jan 9 '17 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.