I am running D7.8 and have gmap and location working out of the box. Everything works, expect for when I am trying to create a map in code. My assumption was to simply call

print theme('gmap',$map)

with $map being an array that has at least the latitude/longitude set. No matter what I do, the map never gets rendered (as a map), and I only end up with the DIV that tells me I need javascript. Looks like the required javascript for the map never fires. When I check Drupal.settings.gmap I can see an object for my map.

Can someone please tell me what I am doing wrong, or what I need to pass into theme('gmap')?

Thanks

Comments

jhm’s picture

Nobody knows the answer to this?

jhm’s picture

Status: Active » Closed (works as designed)

Found the answer here

$map_array2 = array(
    'id' => 'example',
    'maptype' => 'Terrain',
    'width' => '400px',
    'height' => '400px',
    'latitude' => 12.345,
    'longitude' => 12.345,
    'zoom' => 4,
    'align' => 'left',
    'controltype' => 'Small',
    'markers' => array(
      array(
        'text' => 'First Marker',
        'longitude' => 39.3739522204,
        'latitude' => -81.5681648254,
        'markername' => 'lblue',
      ),
      array(
        'text' => 'Second Marker',
        'longitude' => 44.205835001,
        'latitude' => -70.3674316406,
        'markername' => 'orange',
      ),
    ),
  );
  $element2 = array(
    '#type' => 'gmap',
    '#gmap_settings' => $map_array2,
  );
  $output2 = drupal_render($element2);

  echo $output2;