0

I have two content types that work together:

  • "place": a place on a map (via a geolocation field)
  • "object": an object that is in a specific "place" (referenced via an entityreference field)

Several "objects" can be stored in the same "place".

Now I want to display a map showing the location of each object (via geolocation_views).

My problem:

  • either the view shows OBJECTS, but then if there are several objects in the same place, several "pins" will appear on the exact same spot on the map, which doesn't work well (you can only click on the topmost pin)

  • or the view shows PLACES, but then the information about what object is stored in that place is absent.

For now, I have the following:

  1. the main view is the map and shows places
  2. and then I added a second view, as an attachment next to the map; this view lists (textually) all objects, grouped by places.

This works, but it means that the map is pretty much useless: you can click on a place, see its name, but you have no information about the objects and so you have to search the name of this place in the second view and then you will see the objects. Since there are several dozen of places, it's really cumbersome.

Ideally, I'd like that when the user clicks on a "place" on the map, the tooltip shows not only the name and address of the place (it's already the case), but also the list of objects stored in that place.

How can I achieve that?

0

You're incredibly close. What you need to do is incorporate the objects related to the place into the place view itself.

You do this by means of a Relationship. You can find that, when you're editing the view, in the right-hand Advanced column. When you click Add, you'll see something like Entity Reference: Referenced Entity, A bridge to the Content entity that is referenced via your relate field.

This puts the JOIN in the FROM clause of the underlying SQL query.

  • Thanks for your answer. I think you mean the "Entity Reference: ReferencING Entity", since the objects are referencing the places (the field is on the objects). I didn't mention it but I already have this relationship (I use it for an "object type" exposed filter on the view). This indeed allows me to add another "Title" field using this relationship and display the object name in the tooltip. But my problem with that solution is that, if there are several objects in one place, only the first one is listed. Is there a way to group ALL objects referencing ONE place and display them together? – s427 Apr 6 '18 at 14:33
  • My gut instinct says "Yes", but my lack of familiarity with the specific geolocations_views module says, "I'm not entirely sure how or why it wouldn't". It's the end of my day now, and I'm at DrupalCon Nashville next week. In my downtime, I may try to mock something up quickly and see if anything obvious jumps out. – Mike Cermak Apr 6 '18 at 19:33
  • Thanks, that would be appreciated. :) The geolocation_views module basically uses regular fields to build the content of the tooltip, so it's not that different from using the regular "unformatted list" format... as far as I can tell. (It can also use rendered entities instead of fields.) – s427 Apr 6 '18 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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