I've got a map with some popups working well. However, I'd like to display data from some CCK fields in the popup. I've already overridden Drupal.theme.openlayersPopup to change my output, however the feature argument that it receives doesn't appear to include any CCK field data. I did a console.log(feature) in my JS code and the only attributes I see on the feature argument are:

  • body
  • description
  • name
  • title

Any standard way to change what fields get set on the JS feature objects on a map?
Thanks for any tips!

Comments

zzolo’s picture

Component: Behaviors » OL API
Category: feature » support

You should be able to add fields in your View and have them available in the feature data, then they should be available.

neorg’s picture

I didn't understand what zzolo meant It took me some hours before I realized how to use this solution.

1. Add all the fields you want to showup in your OpenLayer popup in the views. Add them by fields.

2. The last flied you have to add is a Global: Custom text field. In this field you can ( in the Text ) you can combine all the field in one field.
Here is an example:

<a href="[path]"><h2>[field_bedrijfsnaam_value]</h2></a><br />
[field_adres_value]<br />
[field_postcode_value] [field_plaats_value]<br />
<br />
[field_telefoon_value]<br />
[field_website_url]<br />
[mail] 

3. Still in views, select "Settings" at the display -> Style: OpenLayers Data (click the gear)
and select the Custom text field at Description Field ( the field with all the combined fields.)

Have fun.

zzolo’s picture

Status: Active » Closed (works as designed)

Thanks @neorg. I am sorry I did not express myself good enough.

Yeah, this is the best way to do this now. In theory you could do JS level theming for the popup if you wanted to. We chose this method because it is more efficient to not have to send over all that markup to JS when we can create it on the fly.

I am hoping to update tutorials in the docs soon.