<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Check out: <a href="http://dev.openlayers.org/releases/OpenLayers-2.12/examples/styles-context.html">http://dev.openlayers.org/releases/OpenLayers-2.12/examples/styles-context.html</a><div><br></div><div>that should give you a clue on how to handle this.</div><div><br></div><div>Best regards,</div><div>Bart</div><div><br></div><div><div>
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><div>-- <br>Bart van den Eijnden<br>OpenGeo - <a href="http://opengeo.org/">http://opengeo.org</a><br>Expert service straight from the developers.</div><div><br></div></span><br class="Apple-interchange-newline">

</div>
<br><div><div>On Nov 5, 2012, at 5:12 PM, eriktronic <<a href="mailto:etimmers@gmail.com">etimmers@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">As I could not find an clear answer anywhere on google, I subscribed here to<br>hopefully get some help from you.<br><br>I build a map containing a lot of feature points, shown as small dots. As I<br>zoom out I would like the circles to shrink, otherwise the underlying<br>OpenStreetMap is completely lost. I tried doing so by applying a default<br>style and adding a function to the event 'zoomend'. See this small example:<br><br><br>var geoJson = {...}; // some geojson object<br>var style = { 'pointRadius': 3, 'color': '#000000', 'fillColor': '#ffffff'<br>};<br>var map = new OpenLayers.map('map');<br>var layer = new OpenLayers.Vector.Layer('layer', {'style': style} );<br>var format = new OpenLayers.Format.GeoJSON({<br>    'internalProjection': new OpenLayers.Projection("EPSG:900913"),<br>    'externalProjection': new OpenLayers.Projection("EPSG:4326")<br>});<br>layer.addFeatures(format.read(geoJson));<br>map.addLayer(layer);<br>map.events.register('zoomend', layer, function(event) {<br>  var zoom = event.object.getZoom();<br><br>  if (zoom > 13)<br>    style.fillColor = '#ff0000'; // red (R)<br>  else<br>    style.fillColor = '#ffffff'; // white (W)<br><br>  // adding the next line solves the problem, <br>  // but to me it makes no sense<br>  // as the layer will be redrawn twice<br>  // in this case<br>  this.redraw();<br>});<br><br><br>This example gives each zoom level either<br>red (R) or white (W) features:<br><br><br>Apparently, changing the style will only be applied in the next zoom level,<br>as the features have already been processed.<br>For me this is undesired, is there any way to change the style AFTER zooming<br>and BEFORE applying the style / redrawing the features?<br><br>Many thanks in advance!<br><br>Regards,<br>Erik<br><br><br><br>--<br>View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/change-layer-style-on-zooming-tp5014035.html">http://osgeo-org.1560.n6.nabble.com/change-layer-style-on-zooming-tp5014035.html</a><br>Sent from the OpenLayers Users mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>http://lists.osgeo.org/mailman/listinfo/openlayers-users<br></blockquote></div><br></div></body></html>