[OpenLayers-Dev] [OpenLayers-Trac] [OpenLayers] #1260:
SelectFeature and OpenLayers.Feature.Vector.style["select"]
Andreas Hocevar
andreas.hocevar at gmail.com
Thu Jan 17 08:49:06 EST 2008
Christopher Schmidt wrote:
> On Thu, Jan 17, 2008 at 02:46:04PM +1100, Roald de Wit wrote:
>
>
>> - Control.SelectFeature adds the feature to the array of
>> layer.selectedFeatures, it then calls layer.drawFeature(feature)
>> - layer.drawFeature checks if the feature is in the list of
>> selectedFeatures. If so, it fetches feature.style.select. If not, it
>> takes feature.style.default.
>> - when layer.drawFeature is called with a second parameter, that can be
>> a style object or a name describing the render intent that is used to
>> lookup the style from the hash.
>>
>
> Alternatively, Control.SelectFeature -- since it knows that the feature
> is being selected -- is the one to check whether the feature has a
> 'feature.style.select', and draws it (using drawFeature) with that
> style, rather than checking it in drawFeature. The end result is the
> same, I think. I prefer for drawFeature to not depend on
> selectedFeatures -- in my mind, that array is 'managed' by the
> SelectFeature control, so it should be the one doing the logic there.
>
>
I was thinking about other classes that also draw features, like
Control.ModifyFeature. Many of them currently use layer.drawFeature. In
the future, they could all use renderer.drawFeature, and just pass the
renderIntent. In that case, we could probably avoid code duplication
when doing fallback checks in renderer.drawFeature instead of every
other class that needs to draw features.
Legacy support for style hashes and OpenLayers.Style without a style map
should be done in Control.SelectFeature, Control.ModifyFeature etc.,
because if there is no style map, a style instead of a renderIntent
string would be passed to renderer.drawFeature, and those classes might
have a style property (like selectStyle in Control.SelectFeature).
Does this make sense?
Regards,
Andreas.
More information about the Dev
mailing list