<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap; ">Hi peoples, i have a question for all you, the main code of my project is this, and i have dudes, because maibe, there are problem beetwhen "OpenLayers.Control.ModifyFeature" and "OpenLayers.Control.SelectFeature"
and i want to know if i have to take a care when i use them in a same app, here is my code below, take a look and tell me about it, because i have
//------------------------------------------------------------------------------------------------------
feature.layer is null
<a class="moz-txt-link-freetext" href="http://localhost/personal/assets/ge/OpenLayers-2.11/lib/OpenLayers/Control/SelectFeature.js">http://localhost/personal/assets/ge/OpenLayers-2.11/lib/OpenLayers/Control/SelectFeature.js</a>
Line 324
//------------------------------------------------------------------------------------------------------
and it occurr when i select a feature and save changes in it and next i try to select another feature
//------------------------------------------------------------------------------------------------------
modifyControl = new OpenLayers.Control.ModifyFeature(vlayer,
{
autoActivate : true,
onModificationStart : function(feature)
{
ll=feature.geometry.getBounds().getCenterLonLat();
console.log(ll);
},
onModificationEnd : function(feature)
{
if (intersec(feature))
{
}
else
{
Ext.MessageBox.show({
title: 'Error',
msg: 'Esta intentando mover puntos fuera de lo permitido',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
}
modifyControl.unselectFeature(feature);
}
}
);
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">drawControl = new OpenLayers.Control.DrawFeature(
vlayer,
OpenLayers.Handler.Point,
{
handlerOptions :
{
multi : false
},
featureAdded : function(feature)
{
if (intersec(feature))
{
}
else
{
Ext.MessageBox.show({
title: 'Error',
msg: 'Esta intentando insertar puntos fuera de lo permitido',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
vlayer.removeFeatures([feature]);
}
}
});<pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap; "></pre><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">selectvlayer = new OpenLayers.Control.SelectFeature([vlayer, vlayerMunicipios],
{
hover : true,
highlightOnly : true,
clickout : false,
toggle : false,
multiple : false,
allowSelection : false,
click : true,
clickFeature : function (e)
{
if(featureGrid.collapsed == true)
{
if((e.fid == "uneMunicipios.70") || (e.fid == "uneMunicipios.149"))
{
map.zoomToExtent(e.geometry.getBounds(), true);
}
else
{
popup(e);
}
}
else
{
}
}
});
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">featureGrid = new Ext.grid.EditorGridPanel({
ref : "featureGrid",
collapsible : 'true',
animCollapse : true,
collapsed : true,
title : "Feature Table",
region : "south",
height : 150,
sm : new GeoExt.grid.FeatureSelectionModel(),
store : new Ext.data.Store(),
columns : [],
listeners : {
"beforecollapse" : function(p,a) {
selectvlayer.activate();
modifyControl.deactivate();
},
"beforeexpand" : function(p,a) {
selectvlayer.deactivate();
modifyControl.activate();
}
},
sm : new GeoExt.grid.FeatureSelectionModel({
selectControl : modifyControl.selectControl,
autoActivateControl : false,
singleSelect : true
}),
store : new Ext.data.Store(),
bbar : [
{
text : "Eliminar",
handler : function() {
featureGrid.getSelectionModel().each(function(rec) {
var feature = rec.getFeature();
modifyControl.unselectFeature(feature);
vlayer.removeFeatures([feature]);
if (feature.state !== OpenLayers.State.INSERT) {
feature.state = OpenLayers.State.DELETE;
featureGrid.store.featureFilter = new OpenLayers.Filter({
evaluate : function(f) {
return feature !== f;
}
});
vlayer.addFeatures([feature]);
}
});
}
},
new GeoExt.Action({
control : drawControl,
text : "Crear",
enableToggle : true,
ref : 'crear'
}),
{
text : "Guardar cambios",
handler : function() {
featureGrid.store.proxy.protocol.commit(
vlayer.features,
{
callback : function() {
selectedLayer.redraw(true);
featureGrid.store.reload();
}
}
);
}
}
]
});
items.push(featureGrid);
//------------------------------------------------------------------------------------------------------
<pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap; "></pre><pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap; "></pre></pre>
</body>
</html>