[OpenLayers-Users] can't supply id to vector layer

Ruff, Thomas Thomas.Ruff at solers.com
Thu May 22 15:45:51 PDT 2014


I was able to work around this by adding a custom field to the layer initializer and using Map.getLayersBy() instead of Map.getLayer() when I want to get a reference to the layer.
________________________________
From: openlayers-users-bounces at lists.osgeo.org [openlayers-users-bounces at lists.osgeo.org] on behalf of Ruff, Thomas [Thomas.Ruff at solers.com]
Sent: Thursday, May 22, 2014 2:39 PM
To: openlayers-users at lists.osgeo.org
Subject: [OpenLayers-Users] can't supply id to vector layer

In OL 2.13.1 I'm getting this error:

"TypeError: this.container is null" in OpenLayers.debug.js (line 57513)

whenever I supply an id property to my Vector layer during construction.  If I don't set an id on the layer everything works fine, but I want to use the id to find the layer later.  The layer is being added dynamically as shown below.

var icaoLayer = new OpenLayers.Layer.Vector('myFeature', {
    strategies: [new OpenLayers.Strategy.Fixed()],
    id: 'myFeatureId',
    protocol: new OpenLayers.Protocol.WFS({
        url: '/server/wfs',
        version: '1.1.0',
        featureType: 'myFeatureType',
        featureNS: 'namespace',
        srsName: 'EPSG:4326',
        outputFormat: 'json',
        maxFeatures: 1
    }),
    filter: new OpenLayers.Filter.Comparison({
        type: OpenLayers.Filter.Comparison.EQUAL_TO,
        property: 'stationid',
        value: stationId
    }),
    visibility: true
});

icaoLayer.events.register('loadend', icaoLayer, function (evnt) {
    var zoomLevel = 11;
    openLayersMap.moveTo(new OpenLayers.LonLat(evnt.response.features[0].geometry.x, evnt.response.features[0].geometry.y), zoomLevel);
});
openLayersMap.addLayer(icaoLayer);

Is there something wrong with my code?  This seems like a bug but I wanted to ask here before entering it.

Thanks,
Tom



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20140522/35a4ce51/attachment.html>


More information about the Users mailing list