2

I'm adding an ArcGIS tile server to my openlayers tile server options via this javascript API. I have it displaying the map correctly, but it seems stretched out horizontally (I have a feeling the default projection may be causing this).

The URL I'm pointing it to is:

http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/export

And declaring the layer like so:

var layer = new OpenLayers.Layer.ArcGIS93Rest(null, 
        'http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map
         /MapServer/export',
        { layers:"0,1,2" } );

Does anyone know the projection I should be using? The API says I can specify a projection by adding an srs Projection ID property alongside my layers option, but I'm not sure even what the possible values are.

0

3 Answers 3

3

You do not need to define any srs to your ArcGIS93Rest layer if your map projection and service projection is identical.

    var options = {
        projection: new OpenLayers.Projection("EPSG:900913"),
        displayProjection: new OpenLayers.Projection("EPSG:4326"),
        units: "m",
    };

the below code working is working as it should work.

 arcRest= new OpenLayers.Layer.ArcGIS93Rest( "ArcGIS Server Layer",
                'http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map
                 /MapServer/export', 
                {layers: "show:0,2",
                 TRANSPARENT: true},
                {isBaseLayer: false,
                 extractAttributes: true});


                 
  map.addLayer(arcRest);
0
2

So no matter what I tried and the different projections I used, the map would still appear stretched out.

I did, however, find a little hacky solution using the tile server at http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile. This works out very well. By translating the OSM url parameters, I leveraged the OSM layer API in OpenLayers to work for the ArcGIS server.

Here's the code:

var tileServiceURL = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/${z}/${y}/${x}";

layer = new OpenLayers.Layer.OSM(null, tileServiceURL, {
    transitionEffect: 'resize',
    wrapDateLine: false
});

For now this suits my needs perfectly.

0
1

you can get to that information right on the rest endpoint.
http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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