[OpenLayers-Users] Feature attribute editing/updating
Jean-François Gigand
jf at geonef.fr
Fri Aug 19 10:51:30 EDT 2011
Strange... The method is missing from the apidocs!
The current 2.11 apidocs are complete:
http://dev.openlayers.org/docs/files/OpenLayers/Control/SelectFeature-js.html
I just checked, it does exist (2.10 and 2.11):
OpenLayers.Control.SelectFeature.prototype.unselect (as well as
"select").
Jean-François Gigand - Geonef
Paris, France - http://geonef.fr/
2011/8/19 Dave Potts <dave.potts at pinan.co.uk>:
> Hi
>
> The selectFeature control does not have a unselect method, see
> http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Control/SelectFeature-js.html
> for a list of support interfaces
>
> I am interested in a way of unselecting a feature, I was thinking about
> simulating the right type of event to do this.
>
> D.
>> Hi,
>>
>> I'm not sure to understand what you expect upon updateAttributes() :
>>
>> - update feature style (if it depends on attributes):
>> call feature.layer.drawFeature(feature)
>>
>> - save the attributes back to PostGIS:
>> for that you need OpenLayers.Strategy.Save
>> (with OpenLayers.Protocol.WFS), or maybe you do it with custom
>> code/protocol
>>
>> - unselect the feature (and close the popup)
>> just call selcontrol.unselect(feature)
>>
>> ...
>> What do you need to do exactly?
>>
>> Note: the example you mentioned seems a bit old (2.6 or 2.7). It may
>> be all right but be aware of it!
>>
>>
>> Jean-François Gigand - Geonef
>> Paris, France - http://geonef.fr/
>>
>>
>>
>>
>> 2011/8/19 killerz <eoinskilleen at gmail.com>:
>>> Hi,
>>>
>>> I hoping that somebody here will be able to help me out as i have spent
>>> days
>>> trying to figure this out and its a vital part of an application im
>>> developing for my university dissertation. I am struggling to update
>>> attributes values via a popup box. My data is stored in PostGIS with a
>>> blank
>>> text column which i want to be able to add text to as I draw a new
>>> feature.
>>>
>>> I have been trying to work from this example:
>>> http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group.html
>>>
>>> I have the popup box with the current value displaying in the text
>>> input(I
>>> entered random values via PostGIS to test it) and an update button but
>>> nothing happens. I not sure if the error is in the update button or in
>>> the
>>> updateattributes function. the example has 2 fields to update so my
>>> mistake
>>> maybe altering it to 1 field but I cant figure it out. I have draw,
>>> modify
>>> geometry, delete and save working with the same layer so the data is not
>>> the
>>> issue. The relevant part of the code is below:
>>>
>>>
>>> function createPopup(feature) {
>>>
>>> var attInfo = feature.attributes['info'] ? feature.attributes['info'] :
>>> "no
>>> info";
>>>
>>>
>>> feature.popup = new OpenLayers.Popup.FramedCloud("pop",
>>> feature.geometry.getBounds().getCenterLonLat(),
>>> null,
>>> '<div>Popup<p> <input id="attInfo_' + feature.id + '"
>>> type="text" style="width:100%" value="' + attInfo +'"> <p><input
>>> id="attBtn_'
>>>
>>> + feature.id + '" type="button" value="Update"
>>> onclick="updateAttributes(\''
>>> + feature.id + '\');"></div>',
>>> null,
>>> true,
>>> function() { selcontrol.unselectAll(); }
>>> );
>>>
>>>
>>>
>>> map.addPopup(feature.popup);
>>> }
>>> function destroyPopup(feature) {
>>> feature.popup.destroy();
>>> feature.popup = null;
>>> }
>>> var selcontrol = new OpenLayers.Control.SelectFeature(points, {
>>> onSelect: createPopup,
>>> onUnselect: destroyPopup
>>> });
>>>
>>> function updateAttributes(fid)
>>> {
>>> feature.attributes.info = document.getElementById("attInfo_" +
>>> fid).value;
>>>
>>> {
>>>
>>>
>>> for(var key in feature.attributes)
>>> { if(key != "info")
>>> {
>>>
>>> var data = document.getElementById('att' + key + '_' +
>>> fid).value;
>>> if(feature.attributes[key] != data)
>>> feature.attributes[key] = data; }
>>> }
>>> }
>>> }
>>>
>>>
>>>
>>> Any help would be appreciated. Information on this seems to be lacking
>>> online any examples that show attribute editing also include many other
>>> complex element making them difficult to examine. Perhaps a simple
>>> example
>>> would be useful.
>>>
>>> Thanks in advance!
>>>
>>> Eoin
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://osgeo-org.1803224.n2.nabble.com/Feature-attribute-editing-updating-tp6703055p6703055.html
>>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>
>
>
>
More information about the Users
mailing list