Before I file this as a bug report, I'll check to see whether I'm doing something wrong.

When I apply a style to a specific map feature via hook_openlayers_map_alter, my style is not represented in the rendered map.
For example:

function MYMODULE_openlayers_map_alter(&$map) {
  $map['layers']['default_map_openlayers_1']['features'][0]['style']['pointRadius'] = 25;
}

In this case, the feature is rendered with the default pointRadius, 6.

Is there a different way I should be doing this?
For what purpose does this alter hook exist otherwise?

CommentFileSizeAuthor
#4 cluster_behavior-2071109-4.patch22.04 KBbasvredeling
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

AaronBauman’s picture

Title: Styles added to individual features via hook_openlayers_map_alter are ignored » Cluster behavior overrides all other style settings
Version: 7.x-3.x-dev » 7.x-2.x-dev
Category: support » bug

I've narrowed down the problem to cluster behavior.

openlayers_behavior_cluster.js defines a styleMap object, which takes precedence over other styles, including those defined directly on a feature.
cluster behavior should reconcile existing style definitions, rather than overriding them completely.

johnhanley’s picture

I don't mean to hijack this issue, but on a related note the cluster text color should not be hard-coded in openlayers_behavior_cluster.js, but instead should be configurable through the interface along with the cluster color settings.

Pol’s picture

@bacteriaman,

Please, could you provide a patch to customize the text-color ?

Thanks!

basvredeling’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
22.04 KB

This patch does quite a lot and needs to be tested thoroughly.

  1. Clustering OpenLayers style rules now inherit the styleMap of ever render-intent. ie: vector select and temporary styles display as meant without impacting the cluster styling. @bacteriaman: I believe this could also remedy your situation.
  2. The label text colour is already configurable BUT the label outline isn't. This patch provides an extra property for this.
  3. I've altered some variable names. Now every Low - Middle - High property is properly prefixed and consistently named.
  4. I've corrected the code style here and there so it conforms a bit better to Drupal standards.
  5. The clustering behavior form is reordered. Labels used to be at the very bottom. I've ordered everything (including the new label_outline property) in Low - Middle - High

Enjoy!

basvredeling’s picture

@bacteriaman, my patch solves your issue. Feel free to review it.

johnhanley’s picture

@basvredeling,

Sorry, I got distracted with other tasks after my original post and never followed up on this issue.

I'm anxious to take your patch for a test drive when time permits. Thanks!

John (aka. bacteriaman)

basvredeling’s picture

Reapplied to latest dev release. Functionality still works fine.

basvredeling’s picture

Cleaning up the issue queue for #2670484: Stable 7.x-2.0 release.

This is a pretty long, but quite simple patch. Please review.