[OpenLayers-Users] Error in SelectFeaute
Slawomir Messner
slawomir.messner at staff.uni-marburg.de
Mon May 9 02:52:43 EDT 2011
Sry, worn topic before.
Hi,
I have a listener on "removelayer" (why there ist no "preremovelayer"
like for addlayer). When a layer is removed then the following function
is called:
deactivateDetails:function () {
if (this.showDetailsSelect !=null) {
this.showDetailsSelect.unselectAll();
this.showDetailsSelect.deactivate();
this.map.removeControl(this.showDetailsSelect);
this.showDetailsSelect.destroy();
this.showDetailsSelect =null;
}
},
After this function other listeners are called at last the listner of
the handler in the showDetailsSelect control which is a
SelectFeature-control. So the function moveLayerToTop is called and the
"this.map is null"-exception is thrown. When I remove the destroy-method
the exception isn't thrown. The question is "When you should call
destroy? Or should I ever call destroy? Or is there an error in destory
of SelectFeature?"
Last but not least the initialization of the SelectFeature:
if (layerinstanceof OpenLayers.Layer.Vector) {
$this =this;
var selectOptions = {
hover:true,
toggle:true,
highlightOnly:true,
clickout:true,
renderIntent:"temporary",
onSelect:function (f) { $this.showDetails(f); },
onUnselect:function (f) { $this.hideDetails(f); }
};
if (this.showDetailsSelect) {
this.deactivateDetails();
}
this.showDetailsSelect =new OpenLayers.Control.SelectFeature(
layer, selectOptions
);
this.showDetailsSelect.clickSelect =this.fixDetailsOnClick;
this.showDetailsSelect.events.register("featurehighlighted",this,this.tooltipDetailsSelect);
this.showDetailsSelect.events.register("featureunhighlighted",this,this.tooltipDetailsUnselect);
this.map.addControl(this.showDetailsSelect);
this.showDetailsSelect.activate();
}
In advance thx for answers and comments.
Slawomir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110509/d44c1a86/attachment.html
More information about the Users
mailing list