HI. I seem to be having issues with the GMap Theme function:

  // create array for gmap
  $map_array['id'] = $gmap_id;
  $map_array['width'] = ($node->field_gmap_width) ? $node->field_gmap_width : '100%';
  $map_array['height'] = ($node->field_gmap_height) ? $node->field_gmap_height : '300px';
  $map_array['latitude'] = ($node->location['latitude']) ? $node->location['latitude'] : '41.9023';
  $map_array['longitude'] = ($node->location['longitude']) ? $node->location['longitude'] : '-87.5391';
  $map_array['maptype'] = ($node->field_gmap_maptype) ? $node->field_gmap_maptype : 'Terrain';
  $map_array['controltype'] = ($node->field_gmap_controltype) ? $node->field_gmap_controltype : 'Large';
  $map_array['zoom'] = ($node->field_gmap_zoom) ? $node->field_gmap_zoom : '7';
  
  // create markers
  $marker = array(
    'text' => 'Hi', //phptemplate_gmapnodelabel_life_map($node, $opt),
    'longitude' => ($node->location['latitude']) ? $node->location['latitude'] : '41.9023',
    'latitude' => ($node->location['longitude']) ? $node->location['longitude'] : '-87.5391',
    //'markername' => ($node->field_gmap_markername) ? $node->field_gmap_markername : 'Green',
  );
  $map_array['markers'][] = $marker;

  return theme('gmap', $map_array);

This is how API.txt describes how to do this. But looking into the code a little I add the following and get the correct map settings but no markers:

  $map_full['#settings'] = $map_array;
  return theme('gmap', $map_full);

Comments

bdragon’s picture

Try specifying 'markername' and 'offset' on the marker.

bdragon’s picture

Status: Active » Closed (fixed)

Assuming you were able to fix it.

Fintan Darragh’s picture

For future reference, the actual cause of this problem was that the 'latitude' and 'longitude' values were mixed up.

So these lines:

'longitude' => ($node->location['latitude']) ? $node->location['latitude'] : '41.9023',
'latitude' => ($node->location['longitude']) ? $node->location['longitude'] : '-87.5391',

...should read:

'latitude' => ($node->location['latitude']) ? $node->location['latitude'] : '41.9023',
'longitude' => ($node->location['longitude']) ? $node->location['longitude'] : '-87.5391',

Hope this helps.

-Fintan