[OpenLayers-Users] Enumerating Features in a WFS Layer and WFS Styling

Robert Sanson SansonR at asurequality.com
Tue Sep 2 19:14:20 EDT 2008


Hi Bill
 
For style, and extracting attributes, here is some example code:
 
var farm_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
                farm_style.strokeWidth = 3;
                farm_style.strokeColor = "#ff0000";
                farm_style.fillOpacity = 0.5;
 
var fbnd = new OpenLayers.Layer.WFS("Selected Farm WFS", 
                "http://10.65.192.1/cgi-bin/agbwfs.exe?farmid="+farmid ( 'http://10.65.192.1/cgi-bin/agbwfs.exe?farmid="+farmid' )+"&",
                {typename: 'farm', maxfeatures: 100},
                {scales: [150000, 10], style: farm_style, extractAttributes: true});
map.addLayer(fbnd);
 
var options = {
                    hover: true,
                    onSelect: function(feature) { 
                    OpenLayers.Util.getElement('selfarm').innerHTML = "<strong>Farm_id:</strong>" + feature.attributes.FARM_ID + " <strong>Par_no:</strong>" + feature.attributes.PAR_ID
                    }
 
                  };
                  var select = new OpenLayers.Control.SelectFeature(fbnd, options);
                  map.addControl(select);
                  //select.handler.stopDown = false;
                  //select.handler.stopUp = false;
                  select.activate();
                }
Regards,
 
Robert S

>>> Bill Thoen <bthoen at gisnet.com> 3/09/2008 11:13 a.m. >>>
I've got a couple questions about WFS layers:

After I load features into a WFS layer, how do I access them via js 
code? I thought these would be in the layer.features array, but even 
though there are features in the layer, the features array is empty.

Second, how do I style WFS features? The default style for linear 
features appears to be solid 1px orange, but I want to apply some 
different styles.

TIA,
- Bill Thoen

_______________________________________________
Users mailing list
Users at openlayers.org 
http://openlayers.org/mailman/listinfo/users 

------------------------------------------------------------------
The contents of this email are confidential to AsureQuality. If you have received this communication in error please notify the sender immediately and delete the message and any attachments. The opinions expressed in this email are not necessarily those of AsureQuality. This message has been scanned for known viruses before delivery. AsureQuality supports the Unsolicited Electronic Messages Act 2007. If you do not wish to receive similar communications in future, please notify the sender of this message.
------------------------------------------------------------------


This message has been scanned for malware by SurfControl plc. www.surfcontrol.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080903/4d8228f6/attachment.html


More information about the Users mailing list