Hi, I posted a question in an older issue (http://drupal.org/node/564964) asking a similar question but given that is for openlayers 6.x that may not be the correct place.
I have created a custom marker using a coded style following the instructions documented here - http://drupal.org/node/620602 (used hook_openlayers_style)
This works fine, in that open layers can see with style and I can apply it to a map. However I want to conditionally change the marker graphic being used based on what is in a field. I followed the instructions in the documentation here - https://drupal.org/node/1585880.
However, I need to be able to access the field object within my custom style, looking at older issue threads this seemed to be possible in 6.x but I cannot find a way to access these fields from within the function in 7.x. Because I need to calculate what is in the field before changing the graphic a simple solution such as using a token within the name of the graphic as provided in the documentation is not viable.
This issue - http://drupal.org/node/1000012 suggests that a style like the one I created are different to style plugins. 6.x seems to include functionality to create style plugins, however looking at the examples included in STYLE_PLUGINS.txt file in 6.x the class used to extend plugins does not appear to exist in 7.x-2.x.
It seems style plugins (which sound like they will do what I want) can be used in 6.x but I see no indication this is available in 7.x - is there an alternative or a work around for this? Or am I going to be left having to use custom views PHP field?
Any guidance or suggestions would be greatly appreciated.
Thanks,
Sam
Comments
Comment #1
sambonner commentedThis question has been answered on a similar issue raised earlier which I bumped (apologies for the duplication) - http://drupal.org/node/1662716#comment-7255406
So style plugins are not supported in 7.x-2.x. Apparently this leaves only hacky solutions available to developers wishing to conditionally change markers if their requirements are more complex than simple token replacement in graphic file names.
Comment #2
polHello,
I'm using OpenLayers for a project these days and I succeeded to export/import my styles using a custom module.
Here's the code I used:
I guess I can close the both issues, feel free to reopen if it's not what you want.