OpenLayers OpenLayers

Ticket #1183 (closed feature: fixed)

Opened 2 years ago

Last modified 2 years ago

Vector style framework with rules and property based styling

Reported by: ahocevar Assigned to:
Priority: major Milestone: 2.6 Release
Component: Feature.Vector Version: 2.5
Keywords: Cc:
State: Complete

Description

Attached is a patch that provides a style framework for OpenLayers. This has already been discussed on the devel list and in #533. A more detailled description will follow.

This patch has the following dependencies:

  • #1133 is needed for it to work at all
  • #1173 is needed for the minScale/maxScale rules to work
  • #1172 fixes a bug for correct display of the example on IE

The patch includes examples and tests, all pass in FF and IE.

Attachments

styles.diff (82.5 kB) - added by ahocevar on 12/01/07 16:09:08.
the complete patch
styles-no-georss-flickr.diff (38.6 kB) - added by ahocevar on 12/01/07 16:10:56.
same as styles.diff, but without the georss-flickr example, because its georss feed prevents the patch from being displayed as html in trac
georss-flickr.diff (43.9 kB) - added by ahocevar on 12/01/07 16:11:36.
just the georss-flickr example
test_Style.patch (0.9 kB) - added by ahocevar on 12/17/07 03:48:33.
with this patch, tests also run in IE.

Change History

12/01/07 16:09:08 changed by ahocevar

  • attachment styles.diff added.

the complete patch

12/01/07 16:10:56 changed by ahocevar

  • attachment styles-no-georss-flickr.diff added.

same as styles.diff, but without the georss-flickr example, because its georss feed prevents the patch from being displayed as html in trac

12/01/07 16:11:36 changed by ahocevar

  • attachment georss-flickr.diff added.

just the georss-flickr example

12/04/07 17:11:48 changed by ahocevar

A detailled explanation of the patch can now be found in the Wiki.

12/15/07 10:20:28 changed by crschmidt

  • status changed from new to closed.
  • state changed from Review to Complete.
  • resolution set to fixed.

I've committed this code in r5429:

Add support for the extremely awesomely super-comprehensive rule based styling that Andreas has been working so hard on. I think this is the single most awesome commit I've ever had the pleasure of committing. The results of this commit are described on http://trac.openlayers.org/wiki/Styles: essentially, this makes it possible to style features in all kinds of fun ways based on rules, and will also form the underlying basis for #533. Things this patch adds:

  • OL.Rule classes. These classes allow you to do tests against the propertie of a feature, and set a style based on these properties -- so you can compare the 'speedlimit' property of a line, and test if it is > 60, and if it is greater than 60, render it in a different color. You can also test combinations of rules using the OL.Rule.Logical class, and test featureids with the FeatureID class.
  • OL.Style class: The OL.Style class lets you wrap up Rules into styles that can be used with drawFeature to draw the feature in the selected style.
  • OL.Layer.Vector.drawFeature will check if the given style is an OL.Style object, and if so, it will draw the feature accordingly.

examples/georss-flickr.html shows usage of these classes.

Many, many thanks go to Andreas for all his hard work on this: this code really is very pretty, and includes unit tests for all the classes (and we know that I am a big fan of tests.)

Three cheers for Andreas: Hip hip, hooray! hip hip, hooray! hip hip, hooray!

No min/max scale yet, but #1173 will take care of that.

(follow-up: ↓ 4 ) 12/17/07 02:53:51 changed by elemoine

test_Style.html fails on IE 7 (haven't checked on IE 6)

(in reply to: ↑ 3 ) 12/17/07 03:48:00 changed by ahocevar

Replying to elemoine:

test_Style.html fails on IE 7 (haven't checked on IE 6)

Attached is a patch that fixes the test..

12/17/07 03:48:33 changed by ahocevar

  • attachment test_Style.patch added.

with this patch, tests also run in IE.

12/17/07 03:57:15 changed by elemoine

test_Style.patch committed in r5466.