c_r_b

Displaying WMS layer from ArcGIS 10 in OpenLayers v2.11

Discussion created by c_r_b on Dec 29, 2011
Latest reply on May 4, 2012 by ytang-esristaff
I'm trying to add an AGS v10 layer to an OL map but it only seems to work if:
- map.projection = WGS84
- map.displayProjection = WGS84
- isBaseLayer = true

My end goal is to use Bing or ESRI cloud-based maps in EPSG:900913 as the base maps, so my map.projection will be EPSG:900913 and my map.displayProjection will be EPSG:4326.  But the only way I can get AGS v10 REST and WMS services to display in an OL map is to set the map.projection, map.displayProjection and layer.projection to EPSG:4326. I'm using OL v2.11.

I have AGS v10 services published as both REST and WMS.  The CRS of the REST service is '102100 (3857)'. EPSG doesn't recognize 102100 which I believe is ESRI's own designation, so I experimented using 3857. If I view the service in an ESRI client (ArcMap, ArcCatalog) then it displays with the correct projection.  But the only way I can display the layer at all in an OL map, whether using a OpenLayers.Layer.ArcGIS93Rest or a OpenLayers.Layer.WMS layer, is to use 4326 for both map.projection and map.displayProjection, which of course will not overlay on top of the Bing/ESRI base layers in EPSG:90013.

While I'd prefer to be able to use WMS, any workaround would be acceptable.  I wasn't able to get WFS to display at all, but that may be because I don't have all the OL layer params that are required.  I tried:

var layer = new OpenLayers.Layer.WFS( 
            "Counties", 
            "http://myserver/arcgis/services/county_wm/MapServer/WFSServer?", 
                        { layers: "0" } 
);


I found this information as well and tried that solution using a map.projection of 3857 for map.projection, map.displayProjection and layer.projection, e.g.:

var options =
{
    'units': 'm'
};

var map = new OpenLayers.Map('gxmap', options);

mapprj = new OpenLayers.Projection("EPSG:3857");
dspprj = new OpenLayers.Projection("EPSG:3857");

map.projection = mapprj;
map.displayProjection = dspprj;

var layer = new OpenLayers.Layer.WMS(
    "Counties",
    "http://myserver/arcgis/services/county_wm/MapServer/WMSServer?",
    {
        layers: "0",
        format: 'image/png',
        srs: 'EPSG:3857'
    },
    {
        opacity: 0.5,
        singleTile: false,
        projection: 'EPSG:3857'
    } 
);


but still no go.  My WMS capabilities file for this layer looks thus:

<Layer queryable="1">
    <Name>0</Name>
    <Title>
        <![CDATA[ county_webmerc ]]>
    </Title>
    <Abstract>
        <![CDATA[ county_webmerc ]]>
    </Abstract>
    <CRS>CRS:84</CRS>
    <CRS>EPSG:4326</CRS>
    <CRS>EPSG:3857</CRS>
    <EX_GeographicBoundingBox>
        <westBoundLongitude>-90.4182892958519</westBoundLongitude>
        <eastBoundLongitude>-82.4134778047652</eastBoundLongitude>
        <southBoundLatitude>41.6961255799368</southBoundLatitude>
        <northBoundLatitude>48.262692384982</northBoundLatitude>
    </EX_GeographicBoundingBox>
    <BoundingBox CRS="CRS:84" minx="-90.4182892958519" miny="41.6961255799368" maxx="-82.4134778047652" maxy="48.262692384982"/>
    <BoundingBox CRS="EPSG:4326" minx="-90.4182892958519" miny="41.6961255799368" maxx="-82.4134778047652" maxy="48.262692384982"/>
    <BoundingBox CRS="EPSG:3857" minx="-10065317.9228131" miny="5115568.65804322" maxx="-9174226.38372922" maxy="6150669.28758651"/>
    <Style>
        <Name>default</Name>
        <Title>0</Title>
        <LegendURL width="32" height="16">
            <Format>image/png</Format>
        <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gis4/arcgis/services/MI/county_wm/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=0" xlink:type="simple"/>
        </LegendURL>
    </Style>
</Layer>


Have also tried using 'crs' for layer instead of 'srs' per this thread, but still no go.

Also worried that the 'isBaseLayer=true' will be required even if I do figure out the projection issue, since I need to display these as overlays.

Has anyone been able to get a non-WGS84 ArcGIS v10 layer -- either REST or WMS -- to display in an OL map?

Outcomes