Hi folks,<div><br></div><div>After a thorough revision of my code, I noticed that when testes OL 2.11 I added this line of code.</div><div>OpenLayers.Layer.Vector.prototype.renderers = ["SVG2", "VML", "Canvas"];</div>
<div><br></div><div>For some reason this screws up my OL 2.10. After deleting this, OL works fine.</div><div><br></div><div>Can anyone explain what that line of code does ?</div><div><br></div><div>What I cant get to work is the property cursor:"pointer" in the style.</div>
<div><br></div><div>I will keep you posted. </div><div><br></div><div>Pointers are always welcome</div><div><br></div><div><br></div><div>Ricardo</div><div><br></div><div><br><br><div class="gmail_quote">2011/6/7 Ricardo Bayley <span dir="ltr"><<a href="mailto:ricardo.bayley@gmail.com">ricardo.bayley@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Folks,<div><br></div><div>I have this code</div><div> </div><div><b> var q = arguments[0];</b></div>
<div><div><b><span style="white-space:pre-wrap">                </span>var format = new OpenLayers.Format.GeoJSON({</b></div>
<div><b><span style="white-space:pre-wrap">        </span> 'internalProjection': map.baseLayer.projection, // 900913</b></div><div><b><span style="white-space:pre-wrap">        </span> 'externalProjection': new OpenLayers.Projection('EPSG:4326')</b></div>
<div><b><span style="white-space:pre-wrap">                </span>});</b></div><div><b><span style="white-space:pre-wrap">                </span>var features = format.read(js);</b></div><div><b><span style="white-space:pre-wrap">                </span>q.layer.addFeatures(features);</b></div>
</div><div><b><br></b></div><div><div><font color="#660000"><b><span style="white-space:pre-wrap">                </span>var z = map.getZoomForExtent(q.layer.getDataExtent())-1;</b></font></div>
<div><font color="#660000"><b><span style="white-space:pre-wrap">                </span>map.setCenter(q.layer.getDataExtent().getCenterLonLat(), z);</b></font></div></div><div><br></div><div><br></div><div>
so far, everything works fine. Layer gets loaded with the features, and the are displayed.</div><div>the last two lines of code are giving me serious trouble. Don't know why, but features get duplicated and are slightly moved as if rendered at different scale or resolution.</div>
<div><br></div><div>As soon as I pan the map, or switch base layers, or do anything that gets the map to "refresh", duplicated features are gone.</div><div>If I don't zoom to the max extent of the layer, I dont get the duplicates.</div>
<div>
I do a console.debug(q.layer) and I don't see any duplicated features. Layer only has 50 features as it should.</div><div><br></div><div>It got me thinking, and since this might also be a styling issue, this is the style I use.</div>
<div><div><br></div><div><div><b> var myStyle = new OpenLayers.StyleMap({</b></div><div><b> "default": new OpenLayers.Style({</b></div><div><b><span style="white-space:pre-wrap">        </span> <span style="white-space:pre-wrap">        </span>cursor:"pointer",</b></div>
<div><b><span style="white-space:pre-wrap">        </span> <span style="white-space:pre-wrap">        </span>graphicZIndex: "${getZIndex}"</b></div><div><b><br></b></div><div><b> },{context:funciones,</b></div>
<div><b> rules: [</b></div><div><b> new OpenLayers.Rule({</b></div><div><b> // a rule contains an optional filter</b></div><div><b> filter: new OpenLayers.Filter.Comparison({</b></div>
<div><b> type: OpenLayers.Filter.Comparison.LESS_THAN,</b></div><div><b> property: "fid", // the "" feature attribute</b></div><div><b> value: 15 // first 15</b></div>
<div><b> }),</b></div><div><b> // if a feature matches the above filter, use this symbolizer</b></div><div><b> symbolizer: {</b></div><div><b> <span style="white-space:pre-wrap">                                </span>graphicHeight: 27,</b></div>
<div><b> <span style="white-space:pre-wrap">                                </span>graphicWidth : 27,</b></div><div><b> externalGraphic: "${getIcon}",</b></div><div><b> graphicYOffset : "${getYOffset}"</b></div>
<div><b> }</b></div><div><b> }), </b></div><div><b> new OpenLayers.Rule({</b></div><div><b> // apply this rule if no others apply</b></div>
<div><b> elseFilter: true,</b></div><div><b> symbolizer: {</b></div><div><b> <span style="white-space:pre-wrap">        </span>cursor:"pointer",</b></div>
<div><b> <span style="white-space:pre-wrap">        </span>pointRadius: 4, // based on feature.attributes.type</b></div><div><b> fillColor: "#5781FC",</b></div>
<div><b> strokeColor: "#000000",</b></div><div><b> strokeWidth: "1"</b></div><div><b> }</b></div><div><b> })</b></div>
<div><b> ]<span style="white-space:pre-wrap">        </span> </b></div><div><b> }),</b></div><div><b> "select":new OpenLayers.Style({</b></div><div><b> graphicZIndex: 101</b></div>
<div><b> })</b></div><div><b> });</b></div></div></div><div><br></div><div>Anyhow, I attach a screenshot so you can see what I am talking about.</div>
<div><br></div><div>Any pointers greatly appreciated</div><div><br></div><font color="#888888"><div>Ricardo</div>
</font></blockquote></div><br></div>