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-boun...@lists.osgeo.org [openlayers-users-boun...@lists.osgeo.org] on behalf of Ruff, Thomas [thomas.r...@solers.com] Sent: Thursday, May 22, 2014 2:39 PM To: openlayers-users@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
_______________________________________________ Users mailing list us...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-users