[OpenLayers-Trac] [OpenLayers] #1120: users should be able to customize the select style per feature
OpenLayers
trac at openlayers.org
Sat Jan 26 11:28:18 EST 2008
#1120: users should be able to customize the select style per feature
-------------------------------+--------------------------------------------
Reporter: tschaub | Owner:
Type: task | Status: new
Priority: minor | Milestone: 2.6 Release
Component: general | Version: 2.5
Resolution: | Keywords:
State: Needs Discussion |
-------------------------------+--------------------------------------------
Changes (by ahocevar):
* state: Needs More Work => Needs Discussion
Comment:
Here are some ideas on a !StyleMap object that would satisfy the
requirement and others as well.
This is what tschaub proposed in #1297:
> At some point, I'd like to see features get a style map with keys that
mapped to arrays of styles. I'm sure this will get crschmidt's hackles up,
but I'd rather have simple constructors and complex objects than just
simple objects (I'm talking here about a more complex style class that has
a nice simple constructor for people who only want orange lines).
I agree with this in principle, although I would see the !StyleMap
object's purpose to manage styles, not arrays of styles. The reason is
that the array of styles resulting from applying a SLD !UserStyle will
differ on a per-feature and per-render base, depending on the fules for
feature properties and map scale. But the result would be the same. A yet-
to-define method in the !StyleMap object before rendering a feature will
return an array of styles, which is the symbolizers for which style rules
applied to:
{{{
!StyleMap.getStyle = function(/*Feature.Vector*/ feature,
/*String*/renderIntent) {
return /*Array*/ styles
}
}}}
This method would look up the appropriate style for the passed
renderIntent (e.g. "select"), and call the Style's creatStyle method with
the {extend: false} option (see the latest patch for #1297), and return
the resulting styles array.
The constructor for the !StyleMap object could have a simple signature for
users who do not care about fancy style processing, with just a style hash
as parameter. This would then be mapped to the "default" renderIntent key.
A more sophisticated signature of the constructor would allow to pass a
hash map of style hashes, keyed by renderIntent. Similar constructor
signatures could take a single Style object as "default" renderIntent, and
a hash of Style objects.
The nice thing about this would be that all methods for translating
between the different style specifications could be encapsulated in the
!StyleMap class.
So all style information a feature or layer needs would then in a single
object.
Does this make sense?
--
Ticket URL: <http://trac.openlayers.org/ticket/1120#comment:6>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list