List, <div><br></div><div>New user testing some backed processing. I am serving GeoJSON polygons through GeoServer to my OpenLayer's client. I have a jQuery button that calls a backend python script and returns data binning. What I am trying to do is recolor my WFS on the client side without redownloading the data.</div>
<div><br></div><div>I have a style that is working on load, but when I attempt to set the layer's new styleMap and refresh I get a blank map. Here is the relevant code - any info appreciated!</div><div><br></div><div>
Map:</div><div><br></div><div><div> map = new OpenLayers.Map('map', options);</div><div> layer0 = new OpenLayers.Layer.Vector("GML", {</div><div> isBaseLayer: true,</div><div>
styleMap: new OpenLayers.StyleMap(style),</div><div> protocol: new OpenLayers.Protocol.HTTP({</div><div> url: "<a href="http://osgeostack:8080/geoserver/fjtests/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=fjtests:counties">http://osgeostack:8080/geoserver/fjtests/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=fjtests:counties</a>",</div>
<div> format: new OpenLayers.Format.GML()</div><div> }),</div><div> strategies: [new OpenLayers.Strategy.BBOX({ratio:3, reFactor:2})]</div></div><div><br></div><div>jQuery Button:</div>
<div><div> $('#mp').click(function(){</div><div> var classes = $('#classes').val();</div><div> var attribute = $('#attr').val();</div><div> $.ajax({</div><div> url:"/cgi-bin/fj_mp.py",</div>
<div> type:"post",</div><div> data: {classes:classes, attribute:attribute},</div><div> success: function(response){</div><div> newMapStyle(classes, response.bins,attribute);</div>
<div><br></div><div> }</div><div> });</div><div> });</div><div> </div></div><div><br></div><div>'Resymbolizer'</div><div><br></div><div><div>function newMapStyle(classes,bins,attribute){</div>
<div> var newstyle = new OpenLayers.Style();</div><div> var ruleArray = new Array()</div><div> var colorMap = [["#D8B365","#F5F5F5","#F5F5F5"],</div><div> ["#A6611A","#DFC27D","#80CDC1","#018571"],</div>
<div> ["#A6611A","#DFC27D","#F5F5F5","#80CDC1","#018571"],</div><div> ["#8C510A","#D8B365","#F6E8C3","#C7EAE5","#5AB4AC","#01665E"],</div>
<div> ["#8C510A","#D8B365","#F6E8C3","#F5F5F5","#C7EAE5","#5AB4AC","#01665E"],</div><div> ["#8C510A","#BF812D","#DFC27D","#F6E8C3","#C7EAE5","#80CDC1","#35978F","#01665E"]]</div>
<div> var index = classes - 3;</div><div> for(var i=0;i<colorMap[index].length;i++){</div><div> (function(){</div><div> var rule = i</div><div> if(i==0){</div><div>
rule = new OpenLayers.Rule({</div><div> filter: new OpenLayers.Filter.Comparison({</div><div> type: OpenLayers.Filter.Comparison.BETWEEN,</div><div> property: attribute,</div>
<div> lowerBoundary: 0,</div><div> upperBoundary: bins[i]}),</div><div> symbolizer: {fillColor:colorMap[i], strokeColor:"black",strokeWidth:0.25}});</div>
<div> </div><div> }else if(i==colorMap[index].length-1){</div><div> var last = i - 1</div><div> rule = new OpenLayers.Rule({</div><div> filter: new OpenLayers.Filter.Comparison({</div>
<div> type: OpenLayers.Filter.Comparison.BETWEEN,</div><div> property: attribute,</div><div> lowerBoundary: bins[last],</div><div> upperBoundary:9999}),</div>
<div> symbolizer: {fillColor:colorMap[i], strokeColor:"black",strokeWidth:0.25}});</div><div> </div><div> }else{</div><div> rule = new OpenLayers.Rule({</div>
<div> filter: new OpenLayers.Filter.Comparison({</div><div> type: OpenLayers.Filter.Comparison.BETWEEN,</div><div> property: attribute,</div><div> lowerBoundary: bins[i-1],</div>
<div> upperBoundary: bins[i]}),</div><div> symbolizer: {fillColor:colorMap[i], strokeColor:"black",strokeWidth:0.25}});</div><div> </div>
<div> }</div><div> </div><div> ruleArray[i] = rule</div><div> }());</div><div> </div><div> }</div><div> newstyle.addRules(ruleArray)</div>
<div> layer0.styleMap = newstyle;</div><div> layer0.refresh({force:true});</div><div> };</div></div>