A projected wanted the marker changed based on whether the node author was logged in or not. My first thought was to make a custom views field that returned differently based on if the user was logged in or not.

Of course, it didn't work since Gmap uses the values, not the rendered values. However, it's not too much extra jogging to find the rendered values.

By rendering the row, which gmap needs to do anyway, the value is stored in the view temporarily at this->view->field[$custom_marker]->original_value and this->view->field[$custom_marker]->last_rendered

However another issue is since the field doesn't exist in the database the field alias isn't relavent. I found the field name at at
$custom_marker= $this->view->display_handler->get_handler('field', $this->options['markerfield'])->options['field'];
though I suspect relationships might make it different :/!

Attached is a working patch to allow, but.. is there a better way to do this?

CommentFileSizeAuthor
gmap_custom_view_marker.patch1.92 KBhefox

Comments

gillesv’s picture

I'm having the same problem. I need the GMap module to take the rendered output of a views field as marker name.
Your patch seemed to work... until I added more than one node to the map.

It seems to use the rendered output of one of the nodes as the marker name for all the nodes. As a result, all the nodes have the same marker.

Have you found a better method for dealing with this in the meanwhile?

hefox’s picture

Hmm, I believe this is working with multiple nodes, and still is working. Can you try debugging it to see what's wrong?

dariogcode’s picture

hefox, nice patch!, thank you. I also experiment same problem that gillesv, all nodes have same marker. I changed this in your patch and it work fine:

else if ($this->options['markers'] == 'field') {
            if (!empty($row->{$marker_field})) {
              $markername = $row->{$marker_field};
            } elseif($this->view->style_plugin->rendered_fields[$row_index][$custom_marker]) {
            	$markername = $this->view->style_plugin->rendered_fields[$row_index][$custom_marker];
            }
          }

Please, can you do a new patch?, I don't know how do that!.

johnv’s picture

Category: support » feature
Status: Active » Postponed (maintainer needs more info)

Closing this very old issue. Please reopen if it is still valid.