0

I have a content type in which the site of organizations are displayed in a leaflet map with the help of an addressfield. (And all organizations are displayed in a joint map.) But certain organizations don't have convertible postal address, therefore geocoding from addressfield doesn't work. For these organizations I created a second geofiled in which I add latitude/longitude values manually.

The problem is that the display of leaflet map in Views can handle only one field as the source of geodata. Is it possible to combine these two geofields into one?

1 Answer 1

0

Have you tried conditional views? You could have 2 fields, using the first by default, and the second instead if the value of the first is empty.
This module has helped me a few times. Just add the module, in your view add a field type "Views conditional", exclude from display your fields and use replacement patterns in your conditional field in one case or the other, depending on the condition (let's say address field is empty, then use latitude/longitude).

EDIT:
What about 3 fields in your content type:

  • Address field [field_address]
  • Lat/long [field_lat_long]
  • Composed field (type text) with token value [field_address][field_lat_long] using field token value or field tokens
    In this way the composed field will always have a value from one or another field, and then you can use this field as data source.
    Then you may need to manage field dependencies to avoid that both fields are used.
5
  • That would be great solution, but unfortunatelly Leaflet Map recognises geofields only as data source.
    – StG
    Nov 1, 2018 at 19:06
  • @StG check my edit
    – Tritof
    Nov 2, 2018 at 11:19
  • It's the same situation: the container field is not a geofield so the leaflet_view submodule doesn't recogineze as geofield even if its content is geodata.
    – StG
    Nov 3, 2018 at 16:18
  • in addition, have you tried to play with computed field drupal.org/project/computed_field and geocoder drupal.org/project/geocoder which seems to be compatible and could be a solution to aggregate 2 fields as I suggested and make it recognised by Leaflet Map?
    – Tritof
    Nov 5, 2018 at 12:39
  • Yeah, thanks. Computed field would be the next possible solution I will try - when I will have a little free time...
    – StG
    Nov 6, 2018 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.