Select to view content in your preferred language

esri/map - invalid url request for map image

1867
8
09-27-2013 11:12 AM
KenGreen
Emerging Contributor
I have put together a website around the esri/map component which displays a nationalmap.gov base layer and then our own map service as a second layer.  It works great for me, but my coworker does not see the base layer when he tries it.  In both cases we are using IE9 on Windows 7.  When I capture the network traffic, I see that his browser does a request for a nationalmap image which results in a "HTTP/1.1 404 Invalid size specified" error:

http://raster.nationalmap.gov/ArcGIS/rest/services/DRG/TNM_Digital_Raster_Graphics/MapServer/export?...

Notice that the url specifies the size as: 641.02,686.02.  The national map requests from my machine always have whole numbers.  If I remove the fractional part of the size and manually request this url in the browser, it works. 

Is this a problem with the national map service for not supporting fractional sizes, or is it a problem with the esri/map component for generating requests with a fractional size.

In either case, any suggestions for a work-around would be appreciated!

Ken
0 Kudos
8 Replies
JohnGravois
Deactivated User
i was able to load the DRG on top of a tiled map service without any trouble.
var map;
require(["esri/map", 
            "esri/layers/ArcGISDynamicMapServiceLayer"
            "dojo/domReady!"], function(Map, ArcGISDynamicMapServiceLayer) {
            
 map = new Map("mapDiv", { 
          center: [-117, 38],
          zoom: 5,
          basemap: "streets"
        });
      
        var myLayer = new ArcGISDynamicMapServiceLayer("http://raster.nationalmap.gov/ArcGIS/rest/services/DRG/TNM_Digital_Raster_Graphics/MapServer/");
        map.addLayer(myLayer);
});


how exactly are you loading the DRG service?  as an ArcGISDynamicMapServiceLayer?  what about your own 'base' service?
0 Kudos
KenGreen
Emerging Contributor
Yes, it works fine for me too.  The problem is that it doesn't work for all clients.  Some clients produce a request to the map service which result in the invalid size error.

Here is how I am loading the map:

var baseLayer = new EsriArcGISDynamicMapServiceLayer("http://raster.nationalmap.gov/ArcGIS/rest/services/DRG/TNM_Digital_Raster_Graphics/MapServer"),
 myLayer = new EsriArcGISDynamicMapServiceLayer(myLayerUrl),
 layersLoaded = 0;

 baseLayer.setScaleRange(54000, 0);

 //...after both layers have loaded:

 map = new EsriMap("map", {
  fadeOnZoom: true,
  navigationMode: "css-transforms",
  logo: false,
  showAttribution: false,
  extent: myLayer.fullExtent
 });

 map.addLayers([baseLayer,myLayer]);


I am using v3.5 of the JSAPI.
0 Kudos
JohnGravois
Deactivated User
i have a hunch that this problem is being caused by the fact that the coordinate system defined for own map service is different than the wkid:102113 which is defined for the DRG map service.

when working with a tiled basemap, you can add it to the map immediately, trust that it will set the spatial reference for the application and then see dynamic map service layers and feature layers reproject on the fly.  since you are working only with dynamic map service layers, i would recommend loading the base layer first and then waiting to load your own layer after the first layer has been loaded successfully.

also, within the map constructor you can't get a reference to the full extent of a layer you haven't loaded yet.

you can do something like this, but i'd actually recommend hardcoding an extent object based on your own service and passing it to the map constructor instead.

var baseLayer = new ArcGISDynamicMapServiceLayer("http://raster.nationalmap.gov/ArcGIS/rest/services/DRG/TNM_Digital_Raster_Graphics/MapServer/");
      
map = new Map("mapDiv", {        
    //even if myLayer has already been instantiated, fullExtent will return null until its actually been loaded in the map
    //extent: myLayer.fullExtent
});
   
map.on("layers-add-result", addDynLayer);   
map.addLayers([baseLayer]);
   
function addDynLayer() {
    map.on("layer-add-result", function(target) {
        map.setExtent(target.layer.fullExtent);
    });  
  
var myLayer = new ArcGISDynamicMapServiceLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/MapServer");
map.addLayer(myLayer);
}   
0 Kudos
KenGreen
Emerging Contributor
My map service is based on spatial reference 102008. 

I also see this problem when using this base map with spatial reference 4326:
http://services.nationalmap.gov/ArcGIS/rest/services/transportation/MapServer

I checked the myLayer.fullExtent and found that it is indeed defined at the point in time when I call the map constructor.

I changed my code to serial the layer loading.  I now load myLayer in the layer-add-result handler for the load of the base map.  It still works for me and and I still find that some other clients have the issue with the invalid size parameter.
0 Kudos
JohnGravois
Deactivated User
what happens when you load an ArcGISTiledMapServiceLayer basemap using a service like this one instead of working with multiple ArcGISDynamicMapServiceLayers?
0 Kudos
KenGreen
Emerging Contributor
It works great, both for me and other clients that tested it - except for one problem.  One of my requirements is that the map be in spatial reference 102008 and since the tiled map services cannot be re-projected, that did not work out.
0 Kudos
JohnGravois
Deactivated User
the first layer you load is going to determine the coordinate system displayed in the application itself, so please try loading your own layer first and confirming whether or not map.spatialReference returns the appropriate 'wkid' in the console.

is your own service available on the public internet? if so, id be happy to take a deeper look.
0 Kudos
KenGreen
Emerging Contributor
I tried reversing the order the layers are loaded, and again it works fine for me and not for the other clients that are having issues with this. 

The site is only available on my companies intranet.

Perhaps I should address this with ESRI support.
0 Kudos