[OpenLayers-Users] SelectFeature addLayer function
Jerome A. Wendell
jawendell at suddenlink.net
Thu Jan 8 08:05:17 PST 2015
Try adding the layer to the map initially with the visibility set to false.
Then use a zoomend event to change the layer to visible at the desired zoom
level. Something like:
map.events.register('zoomend', this, function() {
if (map.getZoom() > your desired zoom level)
yourlayer.setVisibility(true);
});
-----Original Message-----
From: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] On Behalf Of rickm81
Sent: Thursday, January 08, 2015 10:52 AM
To: openlayers-users at lists.osgeo.org
Subject: [OpenLayers-Users] SelectFeature addLayer function
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-tp518058
7.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
More information about the Users
mailing list