[OpenLayers-Users] delete feature & vertices - further
Robert Sanson
SansonR at asurequality.com
Thu Oct 16 16:06:17 EDT 2008
Yes, I actually have select, draw and modify controls:
//Select, Draw and Modify controls - these are specific to the layer
controls = {
select: new OpenLayers.Control.SelectFeature(crops, {callbacks: {'over':feature_info}}),
dpolygon: new OpenLayers.Control.DrawFeature(crops,OpenLayers.Handler.Polygon),
modify: new OpenLayers.Control.ModifyFeature(crops),
delf: new OpenLayers.Control.SelectFeature(crops, {onSelect: function(feature) {crops.destroyFeatures([feature])}})
};
for(var key in controls) {
map.addControl(controls[key]);
}
}
//Later on I have a fucntion for activating, deactivating:
function toggleControl(element) {
mode = element.value;
OpenLayers.Util.getElement('comments').innerHTML = "Mode:" + mode;
if ((mode == "select") || (mode == "modify")){
crop_style.strokeColor = "#0000ff";
}
else {
crop_style.strokeColor = "#ff0000";
}
for(key in controls) {
var control = controls[key];
if(element.value == key && element.checked) {
control.activate();
} else {
control.deactivate();
}
}
crops.onFeatureInsert = function(feature) {
lastFeature = feature;
feature.attributes.prop0 = 'new'; //This should be modified to get actual ID
window.alert("New crop area inserted");
}
}
Thanks,
Robert
>>> "Eric Lemoine" <eric.c2c at gmail.com> 16/10/2008 5:48 p.m. >>>
Hi. Do you also have a modify feature control? The select feature and
modify feature controls are known not to play well together. There
already is a ticket about that, and patch attached to it. Eric
2008/10/16, Robert Sanson <SansonR at asurequality.com>:
> I have tried destroyFeatures, removeFeatures and eraseFeatures and they all
> seem to have the same behaviour. The polygon disappears but the vertices
> remain.
>
> var delf = new OpenLayers.Control.SelectFeature(crops, {onSelect:
> function(feature) {crops.destroyFeatures([feature])}});
> map.addControl(delf);
> delf.activate();
>
> Robert Sanson
>
>>>> Tim Schaub <tschaub at opengeo.org> 5/08/2008 12:13 a.m. >>>
> Hey-
>
> Adorian Ardelean wrote:
>> Hi,
>>
>> After upgrading to OL 2.6, delete feature function does not work
>> correctly:
>> when a polygon or polyline is removed, the lines that define the
>> disappear, but the vertexes not (the vertexes appear as the entity is
>> selected). The code worked flawlessly in previous version. Is something
>> that I have to be aware and/or modify?
>>
>> declaration of control
>> deletefeature: new
>> OpenLayers.Control.SelectFeature(vectors,{onSelect:deleteFeature})
>>
>> delete function
>> function deleteFeature(geometry)
>> {
>> this.layer.removeFeatures(geometry);
>> }
>>
>> Any hint that may solve this issue is appreciated,
>
> I just tried the following and confirmed that the above works.
>
> 1) open http://openlayers.org/dev/examples/draw-feature.html
> 2) draw a polygon (note freehand is true here)
> 3) in the firebug console, run this code:
>
> var del = new OpenLayers.Control.SelectFeature(
> map.layers[3], {
> onSelect: function(feature) {
> map.layers[3].removeFeatures([feature]);
> }
> }
> );
> map.addControl(del);
> del.activate();
>
> 4) click on your polygon to see it removed
>
> I suspect you really want to be calling destroyFeatures instead of
> removeFeatures - unless you call feature.destroy elsewhere.
>
> Tim
>
>> Adorian
>>
>> --
>> Dr. Adorian Ardelean
>> coordinator of myNature Project
>>
>> proiectul myNature
>> str. Rascoala din 1907 nr 12
>> Timisoara 300523
>> Romania
>>
>> http://mybiosis.info/nature/portal.php?pagename=firstpage [a Romanian
>> biodiversity-database]
>> http://mybiosis.info/nature/portal.php?pagename=adorian [CV]
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
> ------------------------------------------------------------------
> The contents of this email are confidential to AsureQuality. If you have
> received this communication in error please notify the sender immediately
> and delete the message and any attachments. The opinions expressed in this
> email are not necessarily those of AsureQuality. This message has been
> scanned for known viruses before delivery. AsureQuality supports the
> Unsolicited Electronic Messages Act 2007. If you do not wish to receive
> similar communications in future, please notify the sender of this message.
> ------------------------------------------------------------------
>
>
> This message has been scanned for malware by SurfControl plc.
> www.surfcontrol.com
>
------------------------------------------------------------------
The contents of this email are confidential to AsureQuality. If you have received this communication in error please notify the sender immediately and delete the message and any attachments. The opinions expressed in this email are not necessarily those of AsureQuality. This message has been scanned for known viruses before delivery. AsureQuality supports the Unsolicited Electronic Messages Act 2007. If you do not wish to receive similar communications in future, please notify the sender of this message.
------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081017/6df0c6b7/attachment.html
More information about the Users
mailing list