Select to view content in your preferred language

Javascript API v2.5 WMSLayer Image Format Bug

713
3
10-20-2011 09:19 AM
KurtisPoettcker
Emerging Contributor
When upgrading to 2.5, it seems that the setImageFormat is ignored by the api. When I set the image format to png, the actual request goes out as .jpeg. The same code using version 2.4 of the api, works as expected. Here is the code for the wms service:

topoBaseLayer = new esri.layers.WMSLayer("http://wms.ess-ws.nrcan.gc.ca/wms/toporama_en");
topoBaseLayer.setVisibleLayers(["limits", "vegetation", "builtup_areas", "designated_areas", "hydrography", "hypsography", "water_saturated_soils", "landforms", "constructions", "water_features", "road_network", "railway", "populated_places", "structures", "power_network", "feature_names"]);
topoBaseLayer.setImageFormat("png");

The network traffic generated by v2.5 is shown in 2.5.jpg and the network traffic generated by v2.4 is shown in 2.4.jpg.

Just wondering if this is a bug in the new version or if I'm somehow not sending the request properly.

Thanks,

Kurtis.
0 Kudos
3 Replies
derekswingley1
Deactivated User
Looks like a bug, thanks for reporting this.

In the meantime, here's a workaround:
var topoBaseLayer = new esri.layers.WMSLayer("http://wms.ess-ws.nrcan.gc.ca/wms/toporama_en");
topoBaseLayer.setVisibleLayers(["limits", "vegetation", "builtup_areas", "designated_areas", "hydrography", "hypsography", "water_saturated_soils", "landforms", "constructions", "water_features", "road_network", "railway", "populated_places", "structures", "power_network", "feature_names"]);
dojo.connect(topoBaseLayer, 'onLoad', function(lyr) {
  lyr.setImageFormat("png");
});
map.addLayer(topoBaseLayer);
0 Kudos
by Anonymous User
Not applicable
Original User: abadata

Thanks so much for the quick reply Derek.

The fix works great.

I appreciate the help,

Kurtis.
0 Kudos
derekswingley1
Deactivated User
Gladly. We'll either fix this or update the docs for the next release(2.6).
0 Kudos