When I set an existing node_reference field on the gmap cck field, I'm getting this error.

And that line refers to the first line of this code;

>
foreach ($nrf as $delta => $item) {
    if (!empty($item['nid']) && is_numeric($item['nid'])) {
      $nids[] = $item['nid'];
      $n = node_load($item['nid']);
      if ($n) {
        $settings['markers'][] = array(
          'label' => $n->title,
          'opts' => array('title' => $n->title),
          'latitude' => $n->locations[0]['latitude'],
          'longitude' => $n->locations[0]['longitude'],
          'markername' => variable_get('gmap_node_marker_'. $n->type, 'drupal'),
          'text' => theme('gmapnodelabel', $n), // TODO:
          //'popuplink' => url('map/query/node/'. $n->nid),
        );
      }
    }