[OpenLayers-Dev] my first control... again
toni hernández
tonidelacalle at gmail.com
Wed Feb 25 04:00:40 EST 2009
can't manage my first control
hi,
I am still trying to develop a new control for my application. The control
is called ParallelLine. I am sorry to bother you with this again.
I copied most of the code from ModifyFeature control as Ivan suggested.
As in the ModifyFeature control, this new control includes a selectControl
variable.
The problem is that when I activate my control the selectControl variables
seems not to be propperly initialized.
To test it, I added an alert to the SelectFeature activate method to see if
it is called when instanciating the selectControl variable of my new
control. And it isn't. I have tried to see what happen when I activate the
original ModifyFeature, and of course, it works fine.
I think I have forgotten to change some url. Otherwise I do not have any
idea what is going on.
I must have you all quite confused.
/////////////////////////////////////////////////////////////////
This is how I call the js files.
/////////////////////////////////////////////////////////////////
<script src="../OpenLayers.js"></script>
<script src="../lib/OpenLayers/Control/ParallelLine.js"></script>
/////////////////////////////////////////////////////////////////
This is how I initialize the parallelLine control
/////////////////////////////////////////////////////////////////
initialize: function(layer, options) {
this.layer = layer;
OpenLayers.Control.prototype.initialize.apply(this, [options]);
var control = this;
var selectOptions = {
geometryTypes: this.geometryTypes,
hover: true,
clickout: this.clickout,
toggle: this.toggle
};
this.selectControl = new OpenLayers.Control.SelectFeature(
this.layer, selectOptions
);
this.layer.events.on({
"beforefeatureselected": this.beforeSelectFeature,
"selectFeature": this.selectFeature,
scope: this
});
// Regiter the events (sigte)
this.layer.events.register("mousemove", this, this.mmove );
this.layer.events.register("mousedown", this, this.mdown );
}
/////////////////////////////////////////////////////////////////
This is how I activate the parallelLine control.
/////////////////////////////////////////////////////////////////
activate: function() {
//this function is called. Sure.
return (this.selectControl.activate() &&
OpenLayers.Control.prototype.activate.apply(this,
arguments));
}
This is the activate method from SelectFeature.js which seems to be never
called.
/*From SelectFeature.js*/
activate: function () {
alert("yes");
if (!this.active) {
this.handlers.feature.activate();
if(this.box && this.handlers.box) {
this.handlers.box.activate();
}
}
return OpenLayers.Control.prototype.activate.apply(
this, arguments
);
}
I promise not to bother you again in one week.
ok two weeks then.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20090225/80d4137f/attachment.html
More information about the Dev
mailing list