I have a view that uses the GMap views style plugin. The data source for the marker is set to 'Geofield'. However the map does now show any markers. I get the following message:

Notice: Undefined index: geofield in gmap_plugin_style_gmap->render() (line 185 of .../gmap/gmap_plugin_style_gmap.inc).

I have managed to fix this by editing the next line:
$geofield_name = 'field_' . $this->options['geofield'];

And changing it into:
$geofield_name = 'field_' . $this->options['markerfield'];

After that change, the markers show up, but the bubbletext does not work. The following message appears:

Notice: Undefined variable: bubbletext_field_obj in gmap_plugin_style_gmap->render() (line 259 of ../gmap/gmap_plugin_style_gmap.inc).

I have managed to fix this by changing the next line:
if ($this->options['bubbletextenabled'] && !empty($bubbletext_field_alias) && !empty($row->{$bubbletext_field_alias})) {

Into:
if ($this->options['bubbletextenabled'] && !empty($this->options['bubbletextfield']) && !empty($this->rendered_fields[$row_index][$this->options['bubbletextfield']])) {

Apparantly the variable $bubbletext_field_alias does not exist and I assumed you want to check if the rendered_fields variable is not empty before rendering it?

Have there been changes to the module that could explain why my changes are necessary to get the GMap working with a Geofield datasource?

Comments

podarok’s picture

Status: Active » Postponed (maintainer needs more info)

can you provide a patch against latest dev for Your fix?

Raphael Dürst’s picture

StatusFileSize
new909 bytes

I just had the same problem and made patch for 7.x-2.3.

marty2081’s picture

Sorry, I did not have time to create a patch so far.

I think the patch in #2 misses the first part of my changes?

Another reason why I didn't create a patch yet is that I'm not sure if my changes are a proper fix (it works in my case). So I was hoping someone would confirm that my changes are correct and then I would create a patch.

marty2081’s picture

StatusFileSize
new3.13 KB

Patch attached (sorry, my patch also contains some space corrections due to sublime autocorrecting that):

marty2081’s picture

Status: Postponed (maintainer needs more info) » Patch (to be ported)
podarok’s picture

#4 looks good

commited pushed to 7.x-2.x

podarok’s picture

Status: Patch (to be ported) » Fixed

status

koppie’s picture

Patch works great. Any word on when we'll get it in a stable version?

podarok’s picture

Status: Fixed » Closed (fixed)

#8 its already in 7.x-2.4-beta1 version

johnv’s picture

Status: Closed (fixed) » Needs work

Sorry for re-opening this, but Marty2081 seems to have his contact form disabled.

Martijn,
Can you tell me more about your Geofield configuration?
Your change broke mine...
see #1926360: Compatibility lost with Geofield (in gmap_plugin_style_gmap.inc).
I use Geofield 7.x-1.1, together with Addressfield, attached to nodes. I use Geocoder to code from Addressfield to Geofield.

marty2081’s picture

@johnv: off couse. It sucks that my patch breaks the functionality in your case :(

I also have an Addressfield that gets geocoded into a Geofield.

First the module versions:
GMap: 7.x-2.3-alpha3+0-dev (including my patch)
Geofield: 7.x-1.1
Geocoder: 7.x-1.2 (probably has nothing to do with this, but just to be sure)

I have a Geofield setup in a field collection with the following settings:
Widget: Geocode from another field
Geocode from field: Location data (addressfield field)
Geocoder: Google Geocoder
Geometry type: Point
Multivalue input handling: Match multiples

johnv’s picture

So, there shouldn't be a difference in module versions, and both our installations must be working fine in parallel.
Possible differences:
- naming of Geofield: mine is 'field_geo'. What's yours?
- is your entity a node, or a 'new ' entity ? Mine are nodes.
- my nodes are composed via Field UI completely. Yours?
- usage of field_collection: I have a node with fields: field_geo, field_addres + others. You have similar, bur wrapped in a field_collection?

I guess reversing the patched line will break your installation, even in 2.4?

Groeten, John

marty2081’s picture

I updated to 7.x-2.4 and after that to 7.x-2.x-dev and the markers no longer show up on the map. However this is not because the markers are not set. When I print the $markers variable from within render() they are perfect including LAT/LON, etc.

When I print the $this->options I still have no $this->options['geofield']; this issue started out with and i DO have $this->options['markerfield'];

@johnv: when you print the options you do have a geofield within the options array?

marty2081’s picture

- The naming of the geofield in my case is: field_contact_geo_location
- My entity is a Field Collection. The field collection is setup as a multiple field within a node. (It is a field collection because there are more fields within the contact_info field collection and there are multple 'contacts' within the node
- My nodes and field collections are completely setup using the field UI (no custom coded fields)
- The Field Collection contains an addressfield, some textfields, a emailfield and a geofield.

marty2081’s picture

It turns out the issue with 7.x-2.4 is an issue with a wrong path to the gmap_markers.js file and has nothing to do with the patch for this issue. See #1929544: Fix for Relative Path from Root to gmap_markers.js to make Markers show.

marty2081’s picture

Today I downloaded the latest dev-version and found out that when I re-save my map views I now get the 'geofield' property. Rolling back to the version I was using before and re-saving the views removes the property again. This means my previous patch can be reverted in the current 7.x-2.x-dev version.

A patch on the latest dev branch is following soon.

marty2081’s picture

Status: Needs work » Needs review
StatusFileSize
new684 bytes

Patch attached.

johnv’s picture

:-)

podarok’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
Issue tags: +Needs tests

ok, pushed to 7.x-2.x-dev
this needs test coverage

podarok’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

The last submitted patch, gmap-revert_markerfield_to_geofield-1907478-16.patch, failed testing.

marty2081’s picture

Why was the version changed to 7.x-1.x? My issue (and supplied patches) are about the 7.x-2.x branch...

johnv’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new13.28 KB

@podarok,
Perhaps you should leave v1.x (Gmaps api v2) as is, and conentrate on v2.x (Gmaps api v3).

Please find attached a more performant version of geofield support.

I needed more time to do the same for else if ($this->options['datasource'] == 'fields') , so that remains untouched.

podarok’s picture

Status: Needs review » Needs work

#23 should be updated with removal changes from other issue patches )))

Perhaps you should leave v1.x (Gmaps api v2) as is, and conentrate on v2.x (Gmaps api v3).

We can support 7.x-1.x with backporting to workflow
all patches create against 7.x-2.x and after fixing - backporting them to 7.x-1.x
this is a good practice for drupal core and we should follow it for the right release roadmaps

johnv’s picture

Status: Needs work » Fixed

Forget #23, and since #17 is committed, this is fixed. It is not valid for 1.x, which is working fine.
Patch #23 is also contained in #1153032-19: Markers doesn't work in a view with the configuration: choose latitude and longitude fields.
Test for Geofield support will be included in #1934122: Gmap Views tests. Needs extending and fixing follow-ups.

podarok’s picture

Status: Fixed » Closed (works as designed)

ok, closed
following up