Looking for some guidance on how to create a custom marker action. In the 6.x-1.x-dev version, there's a marker option to open a link.

Trying to evaluate how i can add another option for a custom behaviour.

Comments

lestu’s picture

can someone answer on this please?

lestu’s picture

Quite easy actually! :)

In file "gmap_settings_ui.inc" add another item to the options array.

  $form['gmap_default']['markermode'] = array(
    '#type' => 'radios',
    '#title' => t('Marker action'),
    '#description' => t('Perform this action when a marker is clicked.'),
    '#options' => array(t('Do nothing'), t('Open info window'), t('Open link'), t('Reorder View by Ajax')),
    '#default_value' => isset($defaults['markermode']) ? $defaults['markermode'] : 0,
  );

In file "gmap_plugin_style_gmap.inc" add an else for that new case.

          if ($this->options['enablermt']) {
            $marker['rmt'] = $row->{$rmt_field};
          }
          else {
            // Marker mode: popup.
            if ($defaults['markermode'] == 1) {
              $marker['text'] = $this->row_plugin->render($row);
            }
            // Marker mode: link.
            else if ($defaults['markermode'] == 2) {
              $marker['link'] = url('node/' . $row_nid);
            }
            // Marker mode: Reorder List
            else if ($defaults['markermode'] == 3) {
              $marker['reorder_list'] = $row_nid;
            }
          }

In file "marker.js" also add an else for the new case.

    // Reorder list by Ajax call
    else if (marker.reorder_list) {
      //open(marker.link, '_self');
      var province = last_province;
      $.ajax({url: "/views/ajax?province="+province+"&sortnid="+marker.reorder_list+"&view_name=Locations_Reverse&view_display_id=attachment_1", success: imageDetails});    
    }

Have fun!