Loading polygons from geoserver via OpenLayers using GeoJSON. My plan is to symbolize using attributes in the GeoJSON. I am struggling to access the attributes. Any insight appreciated:
The geometries are drawing, so I know that the GeoJSON is being passed from the backend to the client.
Wrapped in an init() function and called on page load:
map = new OpenLayers.Map('map', options);
var protocol = new OpenLayers.Protocol.WFS({
url: "http://osgeostack:8080/geoserver/fjtests/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=fjtests:counties",
featureNS: "fj_tests",
featureType: "counties",
outputFormat: 'json',
readFormat: new OpenLayers.Format.GeoJSON()
});
layer = new OpenLayers.Layer.Vector("GML", {
isBaseLayer: true,
//styleMap: new OpenLayers.StyleMap(style),
protocol: protocol,
strategies: [new OpenLayers.Strategy.Fixed()]
});
alert(layer.attributes) \\undefined
alert(layer.features.length) \\ 0
map.addLayer(layer)