[OpenLayers-Users] Loading WMC layers at overlays?
jvanulde
jvanulde at NRCAN.GC.CA
Fri Aug 8 22:50:28 EDT 2008
Hi Bart, thanks for that as I think I am half way there now. The only issue
now is that the layers are not transparent. They are coming from Mapserver
as PNG's. Here is my code:
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 2;
OpenLayers.Util.onImageLoadErrorColor = "transparent";
var layerOptions = {
isBaseLayer: false,
singleTile: true,
buffer: 0,
ratio: 1
};
var format = new OpenLayers.Format.WMC({'layerOptions':
layerOptions});
var map, context;
function initMap()
{
// parse wmc into context object
var wmc = document.getElementById('<%= hidWMC.ClientID
%>').value;
context = format.read(wmc, {map: map});
// construct a map given the context
var mapOptions = {
maxExtent: context.bounds,
projection: context.srs
};
map = new OpenLayers.Map("map", mapOptions);
var baseLayerOptions = {
isBaseLayer: true,
displayInLayerSwitcher: false
};
var fake = new OpenLayers.Layer('fake', baseLayerOptions);
map.addLayer(fake);
map.addLayers(context.layers);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
}
Is there a way to make the layers transparent now that I have loaded them?
I think the problem is elsewhere but need some pointers on where to look. I
have loaded the context in another viewer and the layers come in as
expected.
Bart van den Eijnden wrote:
>
> Hi Joost,
>
> you can pass layerOptions to the Format.WMC constructor in order to do
> this. Code example:
>
> mapfish.OGCUtil.readWMC = function(map, response, noZoom) {
> var format = new OpenLayers.Format.WMC({layerOptions: {isBaseLayer:
> false, singleTile: true, buffer: 0,ratio: 1}});
>
> // remove all layers except the baselayer
> for (var i = map.layers.length-1; i >= 0; i--) {
> if (!map.layers[i].isBaseLayer) {
> map.removeLayer(map.layers[i], false);
> }
> }
>
> map = format.read(response.responseText, {map: map});
> ...
> }
>
> Best regards,
> Bart
>
>> Thanks John, that works. Now I need to know how to convert all of the
>> layers in my WMC to overlay's. Any ideas?
>>
>> -----Original Message-----
>> From: John Pulles [mailto:john.pulles at gmail.com]
>> Sent: Wed 06/08/2008 2:49 PM
>> To: Van Ulden, Joost
>> Cc: users at openlayers.org
>> Subject: Re: [OpenLayers-Users] Loading WMC layers at overlays?
>>
>> 2008/8/6 jvanulde <jvanulde at nrcan.gc.ca>
>>
>>>
>>> Is this possible? I want to add a fake base layer and load all the WMC
>>> layers as overlays. Any ideas on how one would go about doing this?
>>
>>
>> You can add a fake base layer with
>>
>> map.addLayer(new OpenLayers.Layer('None', {isBaseLayer: true}));
>>
>> Regards,
>> John
>>
>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Loading-WMC-layers-at-overlays--tp18859376p18859376.html
>>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at openlayers.org
>>> http://openlayers.org/mailman/listinfo/users
>>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
--
View this message in context: http://www.nabble.com/Loading-WMC-layers-at-overlays--tp18859376p18901731.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list