OpenLayers OpenLayers

Ticket #1432 (closed bug: fixed)

Opened 9 months ago

Last modified 9 months ago

propertyStyles of a Style's default symbolizer will not be parsed unless rules are specified

Reported by: ahocevar Assigned to: ahocevar
Priority: minor Milestone: 2.6 Release
Component: Style Version: 2.5
Keywords: Cc:
State: Complete

Description

If the default symbolizer of a StyleMap or Style object has no rules, property styles (i.e. symbolizer properties with values that are replaced by feature property values) will not be parsed.

The expected behaviour would be that

var styleMap = new OpenLayers.StyleMap({
    pointRadius: "${size}}"
}

results in features that are sized according to their style property. The current behaviour is that this will be ignored, unless rules are added to the style.

The attached patch fixes the issue. The patch contains a modified test to show the problem. All tests pass in IE6 and FF2.

Attachments

1432-r6497-A0.patch (3.0 kB) - added by ahocevar on 03/12/08 11:49:26.

Change History

03/12/08 11:49:26 changed by ahocevar

  • attachment 1432-r6497-A0.patch added.

03/12/08 12:13:18 changed by tschaub

  • state changed from Review to Commit.

Confirmed that tests pass in FF and examples still work. Can you write a little more detail on this ticket about how this works (and why it didn't before)?

I also think a nice styles.html example showing the different style options would be nice (in particular because it's not immediately clear what the tests do and do not cover and an example would let us see what behavior we want to maintain).

That said, I think this is is good to go (especially if you add a detailed comment before committing).

03/12/08 12:31:11 changed by ahocevar

http://trac.openlayers.org/wiki/Styles#UsingPropertyStyles shows the usage of propertyStyles in a way that would not work without the patch for this ticket.

http://www.openlayers.org/dev/examples/georss-flickr.html is not affected by the issue, because rules are added.

The example contained in #1433 is also affected by the issue. It defines a default style like this:

var styleMap = new OpenLayers.StyleMap({
    "default": {
        externalGraphic: "../img/marker-gold.png",
        graphicHeight: 20,
        graphicYOffset: -19,
        rotation: "${angle}",
        fillOpacity: "${opacity}"
    },
    "select": {
        externalGraphic: "../img/marker.png"
    }
})

The rotation will be determined by the value of the angle property of the feature, and the opacity will be determined by the value of the opacity property.

The original test in test_Style.html that is modified by this patch is not affected by the issue, because the substitution of the property styles is done after rules are added to the style. The modified test will fail without the issue being fixed, because it adds the rules after checking for the correct substitution of the property styles.

03/12/08 12:42:17 changed by ahocevar

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

(In [6505]) propertyStyles of a Style's default symbolizer will not be parsed unless rules are specified. r=tschaub (closes #1432)