[OpenLayers-Dev] Unable to set own unique ID on layer.

Mats Norén mats.noren at gmail.com
Wed Mar 18 11:11:38 EDT 2009


Hi,
I'm curious to why the initialize-constructor in Layers.js only
creates the div, addd the eventlisteners etc only if this.id == null ?

Shouldn't it be more along the lines:

/**
     * Constructor: OpenLayers.Layer
     *
     * Parameters:
     * name - {String} The layer name
     * options - {Object} Hashtable of extra options to tag onto the layer
     */
    initialize: function(name, options) {

        this.addOptions(options);

        this.name = name;

        if (this.id == null) {
            this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
        }

        this.div = OpenLayers.Util.createDiv(this.id);
        this.div.style.width = "100%";
        this.div.style.height = "100%";

        this.events = new OpenLayers.Events(this, this.div,
                                            this.EVENT_TYPES);
        if(this.eventListeners instanceof Object) {
            this.events.on(this.eventListeners);
        }

        if (this.wrapDateLine) {
            this.displayOutsideMaxExtent = true;
        }
    }

Or to put it another way, am I not allowed to provide my own unique id
with the options-object?

best regards,
Mats



More information about the Dev mailing list