Hello,

I'm trying customize the openlayers module using cloudmade layers.
How to customize markers ?
I don't see fields to add a custom icon.
How to choose and filter this icon by content type ?

Thanks for your help.

Comments

mcook’s picture

Zen, I was having similar difficulties understanding how to do style customization, and then I found this issue thread. The first reply in that thread explains how to style by content-type -- in your view, you add this sort of code to the "Feature Styles" section of of the view style settings control (click the little widget beside "Style: Openlayers"). You don't have to do anything about the Callback field, just add the required styling code as a "Feature Styles function" -- each time the view adds a marker (or a line or a poly) to the map, it will run this function to decide how to style it.

zen-dupe’s picture

It works very nice. Thank you mcook.

I suspected that's the place for customizing.
I just regret the poor documentation of this subject.
Where I can find more information about feature style ?

tmcw’s picture

Hi zen,

There's more extensive documentation on styling markers on OpenLayers.org. If you can contribute anything more that applies specifically to this module (like reworking that issue conversation into documentation), it would be much appreciated to add it to the Drupal OpenLayers handbook.

zen-dupe’s picture

Thank you for this information and for your help.
I'm trying to learn for the moment, I hope to contribute when I'll master the subject better.
Anyway. Congratulations for this project. OpenLayers has good potential, it's a super alternvative to Gmap.
I hope projects like mapbox emerge soon...

tmcw’s picture

Status: Active » Closed (fixed)

Hi zen,

Yep - there will be a lot of movement in OpenLayers soon, wish you the best of luck with your site

cpaszkiewicz’s picture

Version: 6.x-1.0-beta4 » 7.x-2.0-beta1
Component: OpenLayers UI » OL API
Status: Closed (fixed) » Active

mcook, you say 'just add the required styling code as a "Feature Styles function" '
Where is this? I don't know where to add it.
Thanks.

ditcheva’s picture

I also cannot find, in Drupal 7, in the views section of either the OpenLayers Data overlay or display overlay, where to add this styling code. Can anyone share?

ditcheva’s picture

The way I solved my problem is to add an extra field to my vocabulary called 'Marker URL' (because I want to vary my markers based on terms) and then edited my terms to fill in that field with a custom marker image url that will correspond to that term. You could, of course, alternatively have a field that just specifies a different color, etc per term.

Then -- in my view, I made sure I added this field to the data overlay layer, so that information is available when you're creating my map. You may need to use the vocabulary as a relationship to get to this new field.

Finally -- create a new style in your OpenLayer maps and just use the field (as it is stated in your custom styles section of your view) as the url or color or whatever component of the style you want to replace dynamically....

Hope that helps!

ekes’s picture

Status: Active » Fixed

I've added documentation for this now:- https://drupal.org/node/1585880

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

japo32’s picture

I'll try this with my current project.
Thanks Pal!