I configured a view to show the results in a map setting the option "choose latitude and longitude fields" and selecting a custom float fields to be used as lat/lon. Also i tried to use a geofield to be the data source lat/lon but is not directly supported although in theory you can add two times the field to the views field and select the geofield formatter to lat/lon separated one per instance of the field.

The problem no matter where is the source of the lat/lon when you choose the lat/lon fields, the view doesn't paint the gmap markers. There are other bug reports that suggest a patch http://drupal.org/node/1061444 but doesn't work for me and i discovered that this is other issue.

I'm using the 7.x-1.x-dev version of Gmap and is important to mention that i'm using the 7.x-3.x-dev version of Views. After many hours of debug and looking other reported issues discovered that the problem is in the Gmap Style plugin "gmap/gmap_plugin_style_gmap.inc". Only investigated with the Gmap Style not the Gmap Extended. Not sure if is problem of Views or Gmaps the conflictive lines (start line 94) are:

    // Determine fieldname for latitude and longitude fields.
    if ($this->options['datasource'] == 'fields') {
      $lat_field_obj = $this->view->display_handler->get_handler('field', $this->options['latfield']);
      $lon_field_obj = $this->view->display_handler->get_handler('field', $this->options['lonfield']);
      $lat_field = $lat_field_obj->field_alias;
      $lon_field = $lon_field_obj->field_alias;
    }

The field_alias returned by the get_handler doesn't return the correct name of the field. In the configuration the names of the fields are set without the 'field_' prefix which have all the custom fields when get the field_alias property of the field handler it doesn't return the correct name. As consequence when the render() method try to build de markup the next vars are empty (start line 152):

      foreach ($records as $row_index => $row) {
        $this->view->row_index = $row_index;
        $lat = (float)$row->{$lat_field};
        $lon = (float)$row->{$lon_field};

If the $lat_field is malformed the $row key will be empty, in my case i have a custom float fields named 'field_lat' and 'field_lon' and they are named in the $row object as 'field_field_lon' and 'field_field_lan'. Of course the value is not correctly obtained by the above code and as a result the markers are not properly generated.

I'm working in a patch, but need to test with previous version of Views to discard a bug from that module. If someone else is experimenting this problem we can work together to fix Gmaps, i discover other bugs and noted that the las release was on April 2011 i supose the developers are busy in other things and we can help to stabilize Gmaps.

Thanks.

Files: 
CommentFileSizeAuthor
#21 latlon_after.jpg158.3 KBjohnv
#21 latlon_before.jpg155.1 KBjohnv
#19 gmap2_1153032_19_latlonfields.patch3.03 KBjohnv
PASSED: [[SimpleTest]]: [MySQL] 732 pass(es).
[ View ]
#16 1153032-16.patch664 bytespodarok
PASSED: [[SimpleTest]]: [MySQL] 28 pass(es).
[ View ]
#14 1153032-14.patch1.34 KBpodarok
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1153032-14.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#10 1153032-7.x-1.x.diff3.91 KBpodarok
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1153032-7.x-1.x.diff. Unable to apply patch. See the log in the details link for more information.
[ View ]
#5 style_gmap_customfields_geofields_support.patch4.04 KBcitlacom
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch style_gmap_customfields_geofields_support_0_0.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#1 style_gmap_customfields_geofields_support.patch3.93 KBcitlacom
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch style_gmap_customfields_geofields_support.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

Status:Active» Needs review
StatusFileSize
new3.93 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch style_gmap_customfields_geofields_support.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

As i promised, i was working in the solution of this issue and in the way i found that support a new lat/lon source was very easy, then added support to the geofield type fields. http://drupal.org/project/geofield

I tested the patch using lat/lon source from location.module, geofield.module or custom field as float field separated fields for lat and lon. With this changes the markers work as expected. If someone have the same problems and test it, please give feedback to improve the patch.

I got an error applying the patch.

Hunk #1 FAILED at 88.

I manually applied the patch, but still have no possibility to choose gmap as view style for geofield.

Hi Upupax,

To create a view with Gmap as view style you should follow the next steps:

- create a view with field output as fields and filter the nodes by the content types that have a field of type geofield.
- in the style type there are two options "Gmap" and "Gmap extended" this patch apply only to Gmap style. When you select that style in the configuration you should set the source to "geofield.module" and configure the source field to one of the added fields to your view. Is required to add at least the title and geofield for the fields of your view.
- then if you go to the path of your View you can see the map. I recommend you to review all the Gmap configurations in the path /admin/config/services/gmap

This is a View style and not a field formatter, to make it work you must create a View for the content that you want to geolocate in a map.

StatusFileSize
new4.04 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch style_gmap_customfields_geofields_support_0_0.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Something was wrong generating the first patch, i add it again, now it works applied with command:
patch < style_gmap_customfields_geofields_support.patch at module gmap path.

No way. The map is not displayed at all.
Which versions of Gmap/Views are supposed to work with?

Ok, upgrading to views -dev solved the issue!
Thank you!

Yes worked for me too, just using text fields for long/lat (no geocode module).

It's been nearly a year since this was opened, any plans to include this patch in the next release?

Version:7.x-1.x-dev» 7.x-2.x-dev
Status:Needs review» Fixed

#5 rerolled

thanks!!
commited / pushed to 7.x-2.x

StatusFileSize
new3.91 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1153032-7.x-1.x.diff. Unable to apply patch. See the log in the details link for more information.
[ View ]

the patch against 7.x-1.x

commited / pushed

thanks!

Status:Fixed» Needs work

Hi,
apparently your patch is not working as expected.

I did some debugging and it seems you need to use field_alias anyway.

In your patch you remove

<?php
-      $lat_field = $lat_fied_obj->field_alias;
-     
$lon_field = $lon_field_obj->field_alias;
?>

Can you see there is a misspelling in "$lat_fied_obj"? Is this your mistyping or the original source had this error?!?! Maybe that was the original problem...

I'm using datasource == fields on Views 3.5 and the field names are prefixed in the query with the table name (=field_alias), but this patch uses the field_name instead of field_alias.

So I reverted gmap_plugin_style_gmap.inc from

<?php
      $lat_field
= $this->options['latfield'];
     
$lon_field = $this->options['lonfield'];
?>

to
<?php
     $lat_field
= $lat_fied_obj->field_alias;
    
$lon_field = $lon_field_obj->field_alias;
?>

and from

<?php
                $lat
= (float)$custom_field_lat['value'];
               
$lon = (float)$custom_field_lon['value'];
?>

to
<?php
                $lat
= (float)$row->{$lat_field};
               
$lon = (float)$row->{$lon_field};                 
?>

and now everything works!
If you need a patch file, just let me know

yes, please, provide a patch for review

Status:Needs work» Closed (fixed)
StatusFileSize
new1.34 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1153032-14.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

fixed #12

commited pushed to 7.x-2.x and 7.x-1.x

Status:Closed (fixed)» Needs work

@podarok

Your patch introduced a typo:

$lat_field = $lat_fied_obj->field_alias;

should be

$lat_field = $lat_field_obj->field_alias;

Cheers,

Alex

Version:7.x-2.x-dev» 7.x-1.x-dev
Status:Needs work» Needs review
StatusFileSize
new664 bytes
PASSED: [[SimpleTest]]: [MySQL] 28 pass(es).
[ View ]

fix for 7.x-1.x release

Version:7.x-1.x-dev» 7.x-2.x-dev

commited pushed to 7.x-1.x

the same patch for 7.x-2.x

Status:Needs review» Fixed

tag + http://drupal.org/node/1927012 testing beta

Priority:Critical» Normal
Status:Fixed» Needs review
StatusFileSize
new3.03 KB
PASSED: [[SimpleTest]]: [MySQL] 732 pass(es).
[ View ]

I thought it is better to reopen this, then to open a new issue.
Please see attached patch.
It contains faster, shorter code and aligns better the 3 options location/geofield/fields.

Please test.

Status:Needs review» Needs work
Issue tags:-views, -custom fields, -markers, -bug gmap+Needs tests, +Needs manual testing

would be nice see screenshots before-after for manual testing
#19 looks good for me
+ tag for Needs tests

Status:Needs work» Needs review
StatusFileSize
new155.1 KB
new158.3 KB

Hi, I tested #19 with today's dev version, and i was surprised that the lat/lon fields did not show up at all anymore.
Thi patch fixes this (again).
Please find before and after screenshots of the test views.
You can see the 'Fields' display is empty the first time.

I'm aware we are 'toggleing', regarding this feature.

#21 hmm

#19: gmap2_1153032_19_latlonfields.patch queued for re-testing.

Category:bug» task
Status:Needs review» Needs work

#19 commited pushed to 7.x-2.x
this should be checked for gmapextended too

Component:Code» gmap_plugin_style_gmapextended.inc

changed component as ToDo

This patch assumes that you are working with the Fields API for the "choose latitude and longitude fields" option. It completely breaks my view which is displaying a map of contacts from CiviCRM. Those field names are "geo_code_1" and "geo_code_2". The aliases are "civicrm_address_geo_code_2" and "civicrm_address2_geo_code_2". As you can see prepending "field_" to the field names, doesn't work. In addition, looking at $row->{$lat_field}[0]['raw']['value'] also doesn't work as the data is stored directly in $row->civicrm_address_geo_code_1, etc.

Component:gmap_plugin_style_gmapextended.inc» gmap_plugin_style_gmap.inc

#27 is about the 'normal' plugin. After correcting that, we can 'backport' to GMAP Extended plugin.

actually just tried with the gmap extended plugin and that one works fine.