Hello,

I have a content type called "Adoption case" with a field collection which can add an unlimited number of dogs. This field collection contain an address field. Besides that, "Adoption case" also have a lat/long field.
So here's what I'm trying to accomplish:
adoption case
Please note that the map will be a block displayed on the node page, not inside a field collection. The lat/long belongs to the node and each field collection item contain an address field.

As 2_dogs-OK.png shows, everything works fine as long as only the field collection items are on the map (view_2_dogs_map_settings-OK.png shows the view settings).

The problem appear when I try to show the lat/long field (that belongs to the node) and the address fields (field collection items), together .
Here's the view settings:
wrong

And here's the output:
wrong

I tried a lot of settings but none worked...

Can somebody please tell me what is wrong here?

Thank you!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gge’s picture

I made a small mistake trying to explain my problem... The first image illustrate 3 address while the others show only two. However, the field collection is unlimited.

To summarize, on the map should be displayed all the addresses that come from the field collection, plus the other location (lat/long geofield) from the node itself.

RdeBoer’s picture

Hi gge,

Thank you for persisting with IPGV&M.

And what a lovely good course it is that you appear to be working on!

From your screenshot it appears that Rocky and Louis are displayed in the same location because the Node Coordinates as shown in your screenshot are identical.
So it seems that IPGV&M takes the lat/lon of the second field, ignoring the first?
Maybe changing the order of these two lat/lon fields would solve it? Or would you then not see the Node Coordinates marker?

If not, then one thing I often do to get a better handle on the Views output is to add an identical Attachment formatted as a Table.
Then what I would try and do is to tweak your View to see the desired tabular output and if you have two columns with lat/lon to maybe use Views PHP and a (simple condition as code snippet) to blank out one of the pairs in each row depending on the nature of the data in that row.

Rik

PS: you can change marker colour using IPGV&M's differentiator and a suitable field that has different values for dogs and adoption cases (or a field that exists for one but not the other perhaps?)

PS2: another option might be to simplify your data structure and use a multi-Address field, rather than a Field Collection?

gge’s picture

FileSize
84.31 KB
11.27 KB

Hello and thank you for your reply.
I think I didn't make myself clear enough.
The "Node Coordinates" is actually the location of the shelter and this value never changes. It does not belong to a "Field Collection item".

Here's how the data is structured:
node

To list all the pups that belong to an "Adoption case" is easy and work as expected. These settings produce this map. Two field collection items (pups) listed on the case, two markers on the map. This is perfect!
The problem appear when I try to add the location of the shelter ("Node coordinates" - the lat/long field). This field has nothing to do with those field collection items. The small table under this map is actually the attachment you mentioned in your reply. This attachment is also wrong because the "Node coordinates" has nothing to do with dogs.
In order to get the desired result I think that table should look like this...

PS: This website is for some very close friends who actually saved several hundreds of dogs... They put a lot of effort in what they do and I'm trying to build their website using your wonderful module(s) to better reflect what they do.

gge’s picture

All the coordinates are generated using the combo you mentioned somewhere else: Address Field, Geofield and Geocoder.

RdeBoer’s picture

Hi gge,
Thank you for the pictorial explanation!

This (shelter) field has nothing to do with those field collection items.
I understand that. So do you or do you not want to see it on the map? If not, then do not select it in the IPGV&M settings.

You write "The attachment is also wrong...."

I am now confused as to what you want. I thought the problem was that you were seeing either the shelter or the dog locations but not all of them together.
Are you in fact saying that the problem is that the shelter marker is duplicated?

You have a View that produces:
1 row with lat/lon for Rocky (in Leipzig) and lat/lon for the shelter (in Romania)
1 row with lat/lon for Louis (North of Munich) and lat/lon for the (same) shelter in Romania

So IPGV&M will produce 1 marker for Rocky plus 1 marker for the shelter plus 1 marker for Louis plus 1 marker for the shelter (again).

In total 4 markers, 2 for the dogs and 2 for the same shelter in the same location (so 2 markers on top of each other), because that is what your View outputs.
There is no way for IPGV&M to filter out the second copy of the shelter -- unless you manage to do that in your View.

That is exactly my point about the attachment. Both map and attachment are ways to format the same Views output. We need to tweak the Views output in such a way that it produces the right data in the attachment table. Then your map will be fine too.

I may still misunderstand you, but I have the feeling we have a Views issue, not an IPGV&M issue. Is that right? Do you feel there is a bug in IPGV&M?

gge’s picture

Hi,

I need that view to output the following:

1 row with lat/lon for Rocky (in Leipzig),
1 row with lat/lon for Louis (North of Munich),
1 row with lat/lon for the shelter location.

And the IPGV&M to produce:
1 marker for Rocky,
1 marker fur Louis,
1 marker for the shelter.

I also tried to remove the lat/long field from the "Adoption case" content type and add it to a different content type but the same thing...
Can't say it's a Views (or IPGV&M) limitation because I'm sure these modules can do lots of things that I have no idea about...

RdeBoer’s picture

Hi gge,

Ok good, got ya.

So the key is the Views query, as IPGV&M operates on the result rows handed to it by Views. For each row IPGV&M will display the marker or markers on the row that belong to the location field or fields you selected on the IPGV&M configuration panel.

So if you manage rearrange the View to output the 3 rows like you mention above in #6, then IPGV&M will exactly produce what you wish for. If you manage to get the View to output like #6, then the IPGV&M differentiator will work really nicely as well to assign different marker colours, because it is row-based and you can then differentiate by the content type.

The problem is that currently your View does not output like #6. The field collections make it easy to enter data, but hard to create the View we need.

So, as a result, currently the shelter is duplicated.

We need to do something clever with the View or you have to accept the duplicated shelter marker the way it is.

It's the weekend and nothing in terms of a quick and dirty solution springs to mind right now.... sorry.

Rik

gge’s picture

Hi Rik,

The duplicated shelter marker might not be a problem on a Adoption Case node (there are just couple of dogs on each node) but the site will also have a dedicated page with all the dogs (field collection items, not adoption cases) and I think that will be a problem...

RdeBoer’s picture

Hi gge,
At the moment your data structure is "adoption-case-centric" with dogs only existing as fields on an adoption-case.

Maybe you can make your data structure more dog-centric with dogs being entities/content-types as well.

Rather than the adoption-case "having" multiple dogs, each dog would have an entity reference to zero or one adoption cases.

Then with adoption case and dog being their own entities you do not need one to navigate to the other so you can create a View that has only one copy of each per row. It would simple be a View of all content of type Dog or type Adoption Case.
And each of these rows (markers) can then be assigned a colour via IPGV&M's location differentiator, based on their content type.

At the same time you can still input the link between dogs and adoption cases, via the node Edit tab. But you would link a dog to its adoption case (via the dog's entity reference field) rather than an adoption case to a dog (via a collection field). Or you probably could have the reverse relationship with the AdoptionCase content type having a multi-valued entity reference to dogs. However this could then become a very long Dog multi-selection box on the AdoptionCase edit form. In a former D6 life I developed a solution for thishttps://www.drupal.org/project/cck_reference_filter, but it never got ported to D7.

Whether Dogs refer to AdoptionCases or the other way around, if you want to display in a Views table the dogs belonging to an adoption case, you still can with a slightly different organisation of the View.

With Dogs being entities/content-types rather than fields you can also easily search for them.
And when you click on a Dog marker on the map a balloon will pop up with a link to the AdoptionCase it belongs to.

Finally, entities allow you to move Dogs from one AdoptionCase to another and should an AdoptionCase be deleted, the Dogs won't have to die!

Whichever way you decide to go, as they say in programming, there is a lot to be said for making Dogs first-class citizens!

Rik

gge’s picture

Hi Rik,

And thank you so much for your replies!
I agree that using Field Collection creates problems but I had no choice...
Since all these "adoption cases" and "dogs" will be posted by a volunteer, they needed a fast way to publish everything. The method to create a node for the "case" and after that create a new node for each dog and relate everything seemed complicated/confusing. The website is also multilingual (RO, DE, EN)...
Inline Entity Form or Field Collection seemed perfect for what they need but last time I checked there were some problems when using Inline Entity Form on multilingual sites so I had to chose the other option, Field Collection.

I have to try again Inline Entity Form to see if it can be used on multilingual sites, because with this module I can do exactly what you mentioned (tow different content types: "Adoption case" and "Dogs").

Thank you!

RdeBoer’s picture

That's a shame.
I hope you manage to get Inline Entity Form working for you in a multi-lingual context.
Let us know if and when you reach a new milestone.
Rik

RdeBoer’s picture

Status: Active » Closed (works as designed)

Closed due to inactivity.

crawcole’s picture

FileSize
27.69 KB

Hi Rik,

I have a similar problem to gge. I am trying to create a map block which will reside on a profile page. I have two fields (Birthplace and Other Locations) in the profile content type which term reference a locations vocabulary where I store the location name and coordinates (geofield). Birthplace always has only one value, while Other Locations can have an unlimited amount of values. I'm trying to map both of these on the same map. I can get both to show up, but Birthplace is duplicated. If I have 4 locations referenced in the "Other Locations" field, there are 4 Birthplaces.

table with repeats

You mentioned in #2 that there is a way to potentially blank out components of rows using Views PHP. I'd like to be able to do that to the Birthplace Coordinates of every row but the first one, so they only show up once. Any direction on how to do something like that and integrate the result with IPGVM?