Hi,,,
I have created a gmap page from view module, but there is an error message when viewing the result page. "Notice: Trying to get property of non-object in gmap_plugin_style_gmap->render() (line 105 of /home/xxxxxxxx/public_html/sites/all/modules/gmap/gmap_plugin_style_gmap.inc)" like I attach below.

Please help me,,,,Thanks

Comments

Steven.Pescador’s picture

Hey duniapajak,

Am experiencing the same error and was wondering if you sorted this..?

Cheers.

sensifreak’s picture

same error here :(

mariomc’s picture

Same error here as well!

mariomc’s picture

I managed to solve this issue by rollbacking Views to it's non-dev version.

rollingnet’s picture

StatusFileSize
new163.11 KB

I think this is due to the fact that $row (see line 163 of gmap/gmap_plugin_style_gmap.inc) is an array with multiple locations, as show in the screenshot

rollingnet’s picture

 function render() {

    if (isset($this->view->live_preview) && $this->view->live_preview) {
      return t('GMap views are not compatible with live preview.');
    }

    if (empty($this->row_plugin)) {
      vpr('gmap_plugin_style_gmap: Missing row plugin');
      return;
    }

    $defaults = gmap_defaults();
    $lat_field = 'gmap_lat';
    $lon_field = 'gmap_lon';

    // Determine fieldname for latitude and longitude fields.
    if ($this->options['datasource'] == 'fields') {
      $lat_fied_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_fied_obj->field_alias;
      $lon_field = $lon_field_obj->field_alias;
    }

    $tooltip_field = '';
    if ($this->options['tooltipenabled']) {
      $tooltip_field_obj = $this->view->display_handler->get_handler('field', $this->options['tooltipfield']);
      $tooltip_field = $tooltip_field_obj->field_alias;
    }
    
    $bubbletext_field_alias = '';
    if ($this->options['bubbletextenabled']) {
      $bubbletext_field_obj = $this->view->display_handler->get_handler('field', $this->options['bubbletextfield']);
      $bubbletext_field_alias = $bubbletext_field_obj->field_alias;
    }

    // Determine fieldname for marker field.
    if ($this->options['markers'] == 'field') {
      $marker_field_obj = $this->view->display_handler->get_handler('field', $this->options['markerfield']);
      $marker_field = $marker_field_obj->field_alias;
    }
    
    // Determine rmt field.
    if ($this->options['enablermt']) {
      $rmt_field_obj = $this->view->display_handler->get_handler('field', $this->options['rmtfield']);
      $rmt_field = $rmt_field_obj->field_alias;
    }

    $markername = isset($this->options['markertype']) ? $this->options['markertype'] : 'drupal';

    $markertypes = variable_get('gmap_node_markers', array());
    if ($this->options['markers'] == 'nodetype') {
      $markertypes = variable_get('gmap_node_markers', array());
    }
    elseif ($this->options['markers'] == 'userrole') {
      $markertypes = variable_get('gmap_role_markers', array(DRUPAL_AUTHENTICATED_RID => 'drupal'));
    }

    // Group the rows according to the grouping field, if specified.
    $sets = $this->render_grouping($this->view->result, $this->options['grouping']);

    // Render each group separately and concatenate.  Plugins may override this
    // method if they wish some other way of handling grouping.
    $output = '';
    foreach ($sets as $title => $records) {
      $markers = array();
      $offsets = array();
      $center_lat = NULL;
      $center_lon = NULL;
      $center_nid = NULL;
      $highlight_nid = NULL;

      // We search nid argument used to center map
      if ($this->options['center_on_nodearg'] && $nodehandler = $this->view->display_handler->get_handler('argument', $this->options['center_on_nodearg_arg'])) {
        $center_nid = $nodehandler->get_value();
      }
      if ($this->options['highlight_nodearg'] && $nodehandler = $this->view->display_handler->get_handler('argument', $this->options['highlight_nodearg_arg'])) {
        $highlight_nid = $nodehandler->get_value();
      }

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

$row in the last line is what generates the error

Steven.Pescador’s picture

Slightly relieved that I'm not the only one, was starting to pull my hair out.

As a short term fix I altered the foreach loop on line 161 to...
foreach ($records['rows'] as $row_index => $row) {

And all appears to be working. This doesn't solve the fact that there are 2 arrays found in $records, however working that out is beyond my abilities I think.

jcassano’s picture

This error happens for me whenever I edit the gmap macro in Views under Format -> GMap -> Settings. Editing the marker type under the same settings, for instance, doesn't cause the error.

I don't get the error if I edit the macro when I first set the settings for the GMap Format. So something about changing the macro after saving the view to the database is causing the problem.

Also, the solution provided by SAF13 in the comment above gave me a new error.

dieuwe’s picture

Exact same problem here.

Editing any settings (Format -> GMap -> Settings) generates these error messages:

Notice: Trying to get property of non-object in gmap_plugin_style_gmap->render() (line 166 of /xxx/sites/all/modules/gmap/gmap_plugin_style_gmap.inc).
Notice: Trying to get property of non-object in gmap_plugin_style_gmap->render() (line 167 of /xxx/sites/all/modules/gmap/gmap_plugin_style_gmap.inc).

The solution from #7 just gave me new error messages:

Notice: Undefined index: rows in gmap_plugin_style_gmap->render() (line 164 of /xxx/sites/all/modules/gmap/gmap_plugin_style_gmap.inc).
Warning: Invalid argument supplied for foreach() in gmap_plugin_style_gmap->render() (line 164 of /xxx/sites/all/modules/gmap/gmap_plugin_style_gmap.inc).

GMap works fine with default settings, but as soon as you change one setting it generates the error messages. The only thing you can do is restore the format to default (undoing changes to the settings still generates the errors). Switching the format back to GMap after that works fine until you once again try to modify the settings.

tmcnamara98’s picture

I'm getting the same thing - change view format to "Unformatted List" then back to GMAP, I get my map. But if I do something as insignificant as try to change the marker color, I get the error detailed in the original post.

Arkrep’s picture

StatusFileSize
new129.62 KB

I'm having the same problem... I've noticed that every time the view is saved the "Grouping Field" is getting duplicated .. I've attached a screen shot to illustrate.

gmap

dieuwe’s picture

Assigned: duniapajak » Unassigned

I can confirm that the above happens. Also changing this to "unassigned" since it is.

thummel’s picture

same error here :(

jjmackow’s picture

same issue here too.

Frederic wbase’s picture

Same issues, any progress?

sgabe’s picture

The bug is caused by the grouping fields. A temporary solution is to remove the grouping options like the following.

  // Group the rows according to the grouping field, if specified.
- $sets = $this->render_grouping($this->view->result, $this->options['grouping']);
+ $sets = $this->render_grouping($this->view->result);

I think this is a Views and not a GMap module bug. The grouping functionality is being reworked right now in Views, see #1235994: When RDF is enabled, grouping can behave incorrectly.

Clint Eagar’s picture

I can confirm that the patch in comment #16 works.

sgabe’s picture

@Client Eagar: that is not a patch, but a quick, dirty, hackish workaround to get rid of the error! We need to check if this issue still valid after #1235994: When RDF is enabled, grouping can behave incorrectly is committed.

chapabu’s picture

I've just applied the patch from #1235994: When RDF is enabled, grouping can behave incorrectly and yes, this issue is still valid.

zach harkey’s picture

I'm having this exact same issue. Any changes to the Gmap Format Settings trigger the creation of an new Grouping field, and when saved, the gmap fails to render and throws up a bunch of notices:

Notice: Trying to get property of non-object in gmap_plugin_style_gmap->render() (line 166 of /.../sites/all/modules/gmap/gmap_plugin_style_gmap.inc).

The "quick, dirty, hackish workaround" described in #16 (make changes to gmap_plugin_style_gmap.inc) solves the problem well enough for me.

If you don't want to hack the gmap module, and need things to work, the steps in #10) can also be used as a sort of procedural workaround: If you have to change any of the Gmap Format Settings, first change the Format to something like Grid. Save. Then change it back to Gmap. All of your previous settings will be lost, but your new settings will be saved and the view will render properly -- but you only get one shot to submit the Gmap Format Settings. If you try to submit any other changes, it will spawn a new grouping field and the gmap view will choke.

  • Views 7.x-3.2
  • Location 7.x-3.x-dev
  • Gmap 7.x-1.x-dev
  • GMap Location 7.x-1.x-dev
zach harkey’s picture

Status: Active » Closed (duplicate)

Ok, haiiro.shimeji just posted a patch for this in a duplicate thread.

I'm marking this thread a duplicate since the other thread contains the patch.

#1425448: Error using with views - Grouping field keeps getting recreated

slippast’s picture

Zach's workaround in #20 was perfect. Thank you! Better than hacking the module.

user654’s picture

.

jim005’s picture

same for me and I can confirm that the patch in comment #16 works.

zach harkey’s picture

I really recommend using patch #10 from this thread instead of #16 because it doesn't break the grouping functionality. (Just remember once you apply the patch you will need to change and resubmit the gmap style settings one last time before they take effect.)

profelm’s picture

I can also confirm that the patch from the mentioned thread works. (#10)

stephenward’s picture

Another method that worked for me was to change the view format to something other than Gmap, save, then change it back to Gmap. This treats it the same as setting it the first time, which doesn't cause the error.

ampersat’s picture

I had a similar problem in the latest code. I just wrapped the offending line of code in a check to see if it was an array or not. Yes, it is a hack to work around the issue, but it got the job done.

vivdrupal’s picture

@ pinkonomy - this method works fine - till the module is corrected.