Hi list,<div><br></div><div>I have a vector layer with some points, and when I create a new point, it is added to the vector layer and saved correctly in the datasource.</div><div>But, if I do a zoom in, the only feature I can see is the last new one, the other aren't displayed anymore. </div>
<div>After debuging the code, I've seen that when the success event of the save strategy is raised, there is only the last feature in the layer.. And of course, only that one is drawn.</div><div>When I reload the page, all the new faeatures are loaded and displayed ok in the map.</div>
<div><br></div><div>I do the following to load and create points: </div><div><br></div><div><div>function init(){</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>oSaveStrategyPoint = new OpenLayers.Strategy.Save();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>oSaveStrategyPoint.events.register('success', '', getSaveResult);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>oSaveStrategyPoint.events.register('fail', '', getSaveResult);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>wfsPoints = new OpenLayers.Layer.Vector("WFS Points", {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> strategies: [new OpenLayers.Strategy.BBOX(),</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> new OpenLayers.Strategy.Cluster({ distance: 20, threshold: 10 }),</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> oSaveStrategyPoint],</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> protocol: new OpenLayers.Protocol.WFS({</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> url: "<a href="http://localhost:8080/geoserver/wfs">http://localhost:8080/geoserver/wfs</a>",</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> featureType: "points",</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> srsName: "EPSG:23031",</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> featureNS: "<a href="http://www.mapmap.org/g4wd">http://www.mapmap.org/g4wd</a>",</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> geometryName: "the_geom",</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> extractAttributes: false</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> }),</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> styleMap: myPointStyle,</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> displayInLayerSwitcher: false</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>});</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>map.addLayer(wfsPoints);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>controls = {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> drawPoint:new OpenLayers.Control.DrawFeature(wfsPoints, OpenLayers.Handler.Point, { displayClass: 'olControlDrawFeaturePoint' }),</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> selectPoint:new OpenLayers.Control.SelectFeature(wfsPoints, { onSelect: onSelectFeat, onUnselect: onUnselectFeat }),</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> modifyPoint: new OpenLayers.Control.ModifyFeature(wfsPoints)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>controls.drawPoint.featureAdded = function(feature) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> controls.drawPoint.layer.eraseFeatures([feature]);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> selectedFeature = feature;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> onSelectFeat(feature);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> controls.drawPoint.layer.drawFeature(feature);</div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>for (var key in controls) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> map.addControl(controls[key]);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div><div><br></div><div>function onSelectFeat(feature) {</div>
<div> var szPopupContent;</div><div> selectedFeature = feature;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>feature.state = OpenLayers.State.UPDATE;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>szPopupContent = "<div style='font-size:.8em;font-family:Verdana'>" +</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>"<table style='width: 80%;'>" +</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>"<tr><td>" +</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>"Element:</td><td>" + <a href="http://feature.id">feature.id</a> + "<br />" +</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>"</td></tr><tr><td>" +</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>"Position:</td><td>" + feature.geometry.getBounds().getCenterLonLat() + "<br />" +</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>"</td></tr><tr><td>" +</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>"att_1:</td><td><input id='txtAttribute1' type='text' /><br />" +</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>"</td></tr><tr><td>" +</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>"att_2:</td><td><input id='txtAttribute2' type='text' /><br />" +</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>"</td></tr></table>" +</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>"<input id='btnSave' type='button' value='Save Point' " +</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>"onclick='SaveFeatures()'>" +</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>"</div>";</div><div> </div><div> popup = new OpenLayers.Popup.FramedCloud("chicken",</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>feature.geometry.getBounds().getCenterLonLat(),</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>null,</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>szPopupContent,</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>null, true, onPopupClose);</div>
<div> map.addPopup(popup);</div><div>}</div><div><br></div><div>function SaveFeatures() {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if (controls["drawPoint"].active) {</div><div>
<span class="Apple-tab-span" style="white-space:pre">                        </span>selectedFeature.state = OpenLayers.State.INSERT;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>else {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>selectedFeature.state = OpenLayers.State.UPDATE;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>selectedFeature.attributes.att_1 = document.getElementById("txtAttribute1").value;</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>selectedFeature.attributes.att_2 = document.getElementById("txtAttribute2").value;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>oSaveStrategyPoint.save();</div>
<div>}</div></div>