Ticket #3597 (closed bug: invalid)

Opened 18 months ago

Last modified 18 months ago

OpenLayers.Layer.WMS options - id field

Reported by: fvigetti Owned by: euzuro
Priority: blocker Milestone: 2.11 Release
Component: Layer.WMS Version: 2.11
Keywords: options Cc:
State: Commit

Description

I need to use the id field of the options object when I add a layer, to easily retrive the layer object through the API getLayer, but I verified with Firebug that this id is not effectively stored anywhere. The test of this is that when I call getLayer using this id, I receive a null object. Similarly to this, when I use OpenLayers.Layer.WMS.Post to add a layer, setting the id field in the options object gives me in runtime the following error:

Uncaught TypeError: Cannot call method 'addEventType' of null OpenLayers.Layer.Grid.OpenLayers.Class.initializeOpenLayers.js:1059 OpenLayers.Layer.WMS.OpenLayers.Class.initializeOpenLayers.js:1583 OpenLayers.Layer.WMS.Post.OpenLayers.Class.initializeOpenLayers.js:2689 addLayerfao-widgets-map-js-0.1.js:185 initMapindex.html:32 dispatchEventfao-commons-0.1.js:46 loadfao-widgets-map-js-0.1.js:76 initindex.html:21 (anonymous function)index.html:71 onload

Could you please give me some clarifications for this behaviour? And if I do something wrong? Thanks in advance

Francesca

Change History

Changed 18 months ago by erilem

  • status changed from new to closed
  • resolution set to invalid

Don't rely on id. Give a name to the layer and use map.getLayersByName. (When an id is passed the Layer constructor doesn't create a div for the layer. I can actually not make sense of that.)

Also, please ask questions on the mailing list instead of creating tickets. Tickets are for actual bug reports and requests for enhancement.

Note: See TracTickets for help on using tickets.