[OpenLayers-Users] Loading WMC layers at overlays?
jvanulde
jvanulde at NRCAN.GC.CA
Mon Aug 11 03:08:15 EDT 2008
I didn't realize that I could merge with an existing map object. How would
one do that? Arnd, I did try to loop over the layers in the context before
I added them to my map oject but I can't seem to access any of the
properties. How do I access the transparent property/parameter?
Thanks for helping me out with this.
Bart van den Eijnden wrote:
>
> Hi Arnd,
>
> you're absolute right. I didn't see that Joost was not merging the
> context with an existing map object, like I am doing, in which case you
> don't have that kind of control.
>
> Best regards,
> Bart
>
> Arnd Wippermann wrote:
>> Why not loop over context.layers before adding the layers?
>>
>> Arnd Wippermann
>>
>> -----Ursprüngliche Nachricht-----
>> Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
>> Im
>> Auftrag von Bart van den Eijnden (OSGIS)
>> Gesendet: Samstag, 9. August 2008 12:04
>> An: jvanulde
>> Cc: users at openlayers.org
>> Betreff: Re: [OpenLayers-Users] Loading WMC layers at overlays?
>>
>> Hi Joost,
>>
>> unfortunately there is no easy way to override this at the moment in OL,
>> see
>> also:
>>
>> http://trac.openlayers.org/ticket/1513
>>
>> What you can do is loop over your layers and then set
>> layer.params.TRANSPARENT to 'true', but it might be too late since the
>> layer
>> will have actually been drawn already.
>>
>> Otherwise change the default WMS parameters of OpenLayers,
>>
>> /**
>> * Constant: DEFAULT_PARAMS
>> * {Object} Hashtable of default parameter key/value pairs
>> */
>> DEFAULT_PARAMS: { service: "WMS",
>> version: "1.1.1",
>> request: "GetMap",
>> styles: "",
>> exceptions: "application/vnd.ogc.se_inimage",
>> format: "image/jpeg"
>> },
>>
>> to e.g. format "image/png" and transparent "true".
>>
>> Best regards,
>> Bart
>>
>> jvanulde wrote:
>>
>>> 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--tp18859376p18
>>>>>> 859376.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
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>> --
>> Bart van den Eijnden
>> OSGIS, Open Source GIS
>> bartvde at osgis.nl
>> http://www.osgis.nl
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>
>>
>>
>
>
> --
> Bart van den Eijnden
> OSGIS, Open Source GIS
> bartvde at osgis.nl
> http://www.osgis.nl
>
> _______________________________________________
> 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--tp18859376p18921083.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list