[OpenLayers-Dev] SelectFeature and last/prevHighlighter
Slawomir Messner
slawomir.messner at staff.uni-marburg.de
Tue May 10 01:20:22 EDT 2011
Hi,
the use-case is that we have two SelectFeature controls. One for
selecting features to know to which feature add attributes the other one
for highlighting features that already have certain attributes. So if
you select some features and then highlight some features to see which
one has an attribute then you unhighlight them to un-/select or assign
some attributes the selection disappears. Selecting happens by clicking
or a box, un-/highlight by hover over a row of a table ("legend").
And, if I remember correct, the selected features are still in
selectedFeatures attribute of the layer. This leads, in best case, to a
is confused user when some of the former selected features are not
selected again and then attributes are assigned.
We have to thank you for the effort you all put into the project.
Regards
Slawomir
Am 09.05.2011 18:03, schrieb Eric Lemoine:
> On Monday, May 9, 2011, Slawomir Messner
> <slawomir.messner at staff.uni-marburg.de> wrote:
>> Hi,
>> I have a question. In the unhighlight function if another SelectFeature was the prevHighlighter it is set to the lastHighlighter but then the feature is simply redraw with it's own style/layer style or default renderIntent. Shouldn't this be only in the first to cases of the if-stmt? in the third like in outFeature that the highlight of the "new" lastHighlighter is used?
>> Here the code I'm talking about(Without the comments in it):
>>
>> unhighlight: function(feature) {
>> var layer = feature.layer;
>> if(feature._prevHighlighter == undefined) {
>> delete feature._lastHighlighter;
>> } else if(feature._prevHighlighter == this.id) {
>> delete feature._prevHighlighter;
>> } else {
>> feature._lastHighlighter = feature._prevHighlighter;
>> delete feature._prevHighlighter;
>> }
>> layer.drawFeature(feature, feature.style || feature.layer.style ||
>> "default");
>> this.events.triggerEvent("featureunhighlighted", {feature : feature});
>> },
>>
>> Now how I think it should be:
>>
>> unhighlight: function(feature) {
>> var layer = feature.layer;
>> var newHighlighter = null;
>> if(feature._prevHighlighter == undefined) {
>> delete feature._lastHighlighter;
>> } else if(feature._prevHighlighter == this.id) {
>> delete feature._prevHighlighter;
>> } else {
>> feature._lastHighlighter = feature._prevHighlighter;
>> delete feature._prevHighlighter;
>> newHighlighter = this.map.getControl(feature._lastHighlighter);
>> }
>> if(newHighlighter != null) {
>> newHighlighter.highlight(feature);
>> } else {
>> layer.drawFeature(feature, feature.style || feature.layer.style ||
>> "default");
>> this.events.triggerEvent("featureunhighlighted", {feature : feature});
>> }
>> },
>> When I look at the code of highlight the "featureunhighlighted" should always thrown to a symmetric behavior of un-/highlight or the "featurehighlighted" event should only be triggered in the highlight when there was no _lastHighlighter.
>
> Hi
>
> I'd like to know your exact use-case (control1 does this, control2
> does that, etc.). With that we should be able to write a test-case
> demonstrating that the current code doesn't behave as expected.
>
> Thanks for your effort on that. It's not trivial code.
>
More information about the Dev
mailing list