yo_haha
10 Oct 2012, 2:21 AM
Hi,
I'm trying to add feature edition buttons to an OpenLayers map. For that, I created OpenLayers controls and ExtJs buttons that activate/deactivate those controls when pressed/depressed.
The problem is that when I click on one of those buttons for the first time after page is loaded, I get a javascript error:
TypeError: node.recordIndexToNodeIndex is not a function
This error makes other buttons, that are in the same toggle group with the feature edition buttons, behave strangely.
This strange behaviour disappears after the user performs some toggling between the feature edition buttons and other buttons.
Below, the code of an add line button :
addLine = new Ext.Button({
iconCls: 'addLine',
tooltip: 'ajouter une ligne',
toggleGroup: 'controls',
enableToggle: true,
allowDepress: false,
toggleHandler: function(toggled){
if(toggled.pressed){
drawControls['addLine'].activate();
console.debug('addLine activated');
}
else{
drawControls['addLine'].deactivate();
console.debug('addLine deactivated');
}
}
});
features edition controls are:
drawControls = {
navigate : new OpenLayers.Control.Navigation(),
addPoint : new OpenLayers.Control.DrawFeature(vectors,
OpenLayers.Handler.Point),
addLine : new OpenLayers.Control.DrawFeature(vectors,
OpenLayers.Handler.Path),
addPolygon : new OpenLayers.Control.DrawFeature(vectors,
OpenLayers.Handler.Polygon),
addRectangle : new OpenLayers.Control.DrawFeature(vectors,
OpenLayers.Handler.RegularPolygon, {
handlerOptions : {
sides : 4,
irregular : true
}
}),
modify : new OpenLayers.Control.ModifyFeature(vectors,
OpenLayers.Handler.Click),
erase : eraseF,
addText : add
};
I'm trying to add feature edition buttons to an OpenLayers map. For that, I created OpenLayers controls and ExtJs buttons that activate/deactivate those controls when pressed/depressed.
The problem is that when I click on one of those buttons for the first time after page is loaded, I get a javascript error:
TypeError: node.recordIndexToNodeIndex is not a function
This error makes other buttons, that are in the same toggle group with the feature edition buttons, behave strangely.
This strange behaviour disappears after the user performs some toggling between the feature edition buttons and other buttons.
Below, the code of an add line button :
addLine = new Ext.Button({
iconCls: 'addLine',
tooltip: 'ajouter une ligne',
toggleGroup: 'controls',
enableToggle: true,
allowDepress: false,
toggleHandler: function(toggled){
if(toggled.pressed){
drawControls['addLine'].activate();
console.debug('addLine activated');
}
else{
drawControls['addLine'].deactivate();
console.debug('addLine deactivated');
}
}
});
features edition controls are:
drawControls = {
navigate : new OpenLayers.Control.Navigation(),
addPoint : new OpenLayers.Control.DrawFeature(vectors,
OpenLayers.Handler.Point),
addLine : new OpenLayers.Control.DrawFeature(vectors,
OpenLayers.Handler.Path),
addPolygon : new OpenLayers.Control.DrawFeature(vectors,
OpenLayers.Handler.Polygon),
addRectangle : new OpenLayers.Control.DrawFeature(vectors,
OpenLayers.Handler.RegularPolygon, {
handlerOptions : {
sides : 4,
irregular : true
}
}),
modify : new OpenLayers.Control.ModifyFeature(vectors,
OpenLayers.Handler.Click),
erase : eraseF,
addText : add
};