[OpenLayers-Users] ModifyFeature and SelectFeature error

J.Alejandro Martinez Linares islanis at infomed.sld.cu
Thu Sep 6 11:10:03 PDT 2012


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
http://localhost/personal/assets/ge/OpenLayers-2.11/lib/OpenLayers/Control/SelectFeature.js
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);
		}
}
);

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]);
			}
		}
});

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
		  {
		
		  }
      }
});

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);

//------------------------------------------------------------------------------------------------------



--

Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120906/78899144/attachment-0001.html>


More information about the Users mailing list