[OpenLayers-Users] SelectFeature addLayer function

rickm81 rickm81 at yahoo.com
Thu Jan 8 07:52:02 PST 2015


Hello

I have a SelectFeature control on my map that I use for one layer. I would
like to add a second layer to the control after the map is zoomed in.
Unfortunately, the addLayer function to add a vectorLayer is not working for
me. 

Below is the code:
        // Draw Custom Control Panel with Select Feature Control
        var navControl = new OpenLayers.Control.Navigation({ title:
'Pan/Zoom' });
        var editPanel = new OpenLayers.Control.Panel({ displayClass:
'editPanel' });
        editPanel.addControls([

*        new OpenLayers.Control.SelectFeature(vectorLayerA, { 
            displayClass: 'lineButton', title: 'Select Feature',
        })*,
        navControl
        ]);

        editPanel.defaultControl = navControl;
        map.addControl(editPanel);
        editPanel.redraw();

        Then Add Second Layer ...
        // Add Layer
        var wgs84 = new OpenLayers.Projection("EPSG:4326");
        vectorLayerB = new OpenLayers.Layer.Vector("New Layer", {
            styleMap: default_styleMap, projection: wgs84
        });
        vectorLayerB.addFeatures(format_geojson.read(some_json));
        map.addLayer(vectorLayerB);
        // Add Directly to Control in Array
    *    map.controls[7].addLayer(vectorLayerB);*

I have no problem adding layers initially, it is only when I try to add a
layer to the existing control. I'm sure this is a common issue, but I cannot
find a solution. If anyone has suggestions I would appreciate it. Thanks!
        




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/SelectFeature-addLayer-function-tp5180587.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list