Google maps 通过模块以编程方式添加gmap标记

Google maps 通过模块以编程方式添加gmap标记,google-maps,drupal-7,Google Maps,Drupal 7,我一直在研究如何在Drupal7GMAP中添加标记,时间比我承认的要长。我必须通过一个模块而不是视图来完成这项工作的原因是因为客户机规范,我在这里将不进行讨论。下面的代码是我到目前为止所拥有的,我所发现的一切似乎都指向这个方向,我觉得它很正确。但是当我转到页面时,地图上没有显示任何标记。有人能帮我吗 这使用drupal 7 btw的gmaps模块 function rrs_custom_menu() { $items = array(); $items['search-by-towns'] =

我一直在研究如何在Drupal7GMAP中添加标记,时间比我承认的要长。我必须通过一个模块而不是视图来完成这项工作的原因是因为客户机规范,我在这里将不进行讨论。下面的代码是我到目前为止所拥有的,我所发现的一切似乎都指向这个方向,我觉得它很正确。但是当我转到页面时,地图上没有显示任何标记。有人能帮我吗

这使用drupal 7 btw的gmaps模块

function rrs_custom_menu() {
$items = array();
$items['search-by-towns'] = array(
    'title' => 'Search by Towns',
    'page callback' => 'search_by_towns',
    'access arguments'  => array('access content'),
    'type'  => MENU_CALLBACK,
);

return $items;
}
function search_by_towns() {
$query = "SELECT node.title AS node_title, location.lid AS location_lid, location.latitude AS gmap_lat, location.longitude AS gmap_lon, location.name as loc_name, location.street, location.city, location.province, location.postal_code, gmap_taxonomy_node.marker AS gmap_node_marker, taxonomy_term_data.tid AS tid, taxonomy_term_data.vid AS vid, gmap_taxonomy_term.marker AS marker
    FROM 
    {node} node
    LEFT JOIN {location_instance} location_instance ON node.vid = location_instance.vid
    LEFT JOIN {location} location ON location_instance.lid = location.lid
    LEFT JOIN {gmap_taxonomy_node} gmap_taxonomy_node ON node.vid = gmap_taxonomy_node.vid
    INNER JOIN {taxonomy_index} taxonomy_index ON node.nid = taxonomy_index.nid
    INNER JOIN {taxonomy_term_data} taxonomy_term_data ON taxonomy_index.tid = taxonomy_term_data.tid
    LEFT JOIN {gmap_taxonomy_term} gmap_taxonomy_term ON taxonomy_term_data.tid = gmap_taxonomy_term.tid
    WHERE (( (node.status = '1') AND (node.type IN  ('listing', 'town')) AND (taxonomy_term_data.vid = '3') ))
    ORDER BY tid desc";

    $javascript = drupal_add_js();
    $result = db_query($query);
    $marker = array();

    foreach ($result as $res) {
        $text = '<div class="location vcard"> <div class="adr"> <span class="fn">'.$res->loc_name.'</span> <div class="street-address"> '.$res->street.' </div> <span class="locality">'.$res->city.'</span>, <span class="region">'.$res->province.'</span> <span class="postal-code">'.$res->postal_code.'</span> </div> <div class="map-link"> <div class="location map-link">See map: <a href="http://maps.google.com?q='.$res->gmap_lat.'+'.$res->gmap_lon.'">Google Maps</a></div> </div> </div>';

        $marker[] = array(
            'latitude' => $res->gmap_lat,
            'longitude' => $res->gmap_lon,
            'markername' => $res->marker,
            'offset' => 0,
            'text' => $text,
            'opts' => array(
                'title' => '',
                'highlight' => 0,
                'highlightcolor' => '#FF0000'
            )
        );
    }

    $map_array = array(
        'id' => "auto1map",         // id attribute for the map
        'width' => "685px",        // map width in pixels or %
        'height' => "480px",      // map height in pixels
        'latitude' => '36.10237644873644',    // map center latitude
        'longitude' => '-80.8758544921875',  // map center longitude
        'zoom' => 8,              // zoom level
        'maptype' => "Map",       // baselayer type
        'controltype' => "Small"  // size of map controls
    );
    $map_array['markers'] = $marker;

  $output = theme('gmap', array(
      'element' => array(
        '#type' => 'gmap',
          '#gmap_settings' => $map_array,
          '#input'  => FALSE,
          '#theme'  => 'gmap',
          '#children'   => '',
          )
        )
    );

return $output; 
}