I am trying to create a code where a feature is created, and then automatically a popup window will open. Is there anyone who can assist me please?
Here is a part of the code and I want the popup to open right after that one.
var draw = new OpenLayers.Control.DrawFeature(
wfs_layer, OpenLayers.Handler.Point,
{
title: "Create a feature",
displayClass: "olControlDrawFeaturePolygon",
multi: true
});
Later on I have a code for the popup:
//---POPUP fyrir Attribute---//
var select = new OpenLayers.Control.SelectFeature(wfs_layer,{hover: true, highlightOnly: true});
map.addControl(select);
select.activate();
var selectClick = new OpenLayers.Control.SelectFeature(wfs_layer,{});
map.addControl(selectClick);
selectClick.activate();
function onPopupClose(evt) {
select.unselectAll();
}
wfs_layer.events.on({
featureselected: function(event) {
var feature = event.feature;
feature.popup = new OpenLayers.Popup.FramedCloud
("pop",
feature.geometry.getBounds().getCenterLonLat(),
null,
'<form name="inputform">'+
'<table><tr><td align="left">NAME:</td>\
<td align="left"><input name="name" type="text" size="30" maxlength="30" value="'+feature.attributes.nafnfitju+'" ><br></td></tr>'+
'<tr><td align="left">Heimild:</td>\
<td align="left"><input name="source" type="text" size="30" maxlength="30" value="'+feature.attributes.heimild+'" ><br></td></tr>'+
'<tr><td align="left">Code1:</td>\
<td align="left"><input name="addrattara" type="text" size="30" maxlength="30" value="'+feature.attributes.addrattara+'" ><br></td></tr>'+
'<tr><td align="left">Code2:</td>\
<td align="left"><input name="Source1" type="text" size="30" maxlength="30" value="'+feature.attributes.source1+'" ><br></td></tr>'+
'<tr><td align="left">Open/closed:</td>\
<td align="left"><input name="open_closed" type="text" size="30" maxlength="30" value="'+feature.attributes.open_closed+'" ><br></td></tr></table></form>'+
'<p align="left"><input type="submit" value="Save" onClick="javascript:ourfunction(\''+feature.fid+'\')"></p>'+
'<p align="right"><input type="submit" value="Delete" onClick="javascript:delete(\''+feature.fid+'\')"></p>',
null,
true,
onPopupClose
);
map.addPopup(feature.popup);
},
//destroy popup when feature is no longer selected. Prevents showing 2 Popups at the same time
featureunselected: function(event) {
var feature = event.feature;
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
});
Hopefully someone can assist me, thanks in advance.
Sjonni, Iceland