You are here

function gmap_simple_map in GMap Module 6.2

Same name and namespace in other branches
  1. 5 gmap.module \gmap_simple_map()
  2. 6 gmap.module \gmap_simple_map()
  3. 7.2 gmap.module \gmap_simple_map()
  4. 7 gmap.module \gmap_simple_map()

Simple way to draw a map from inside a theme.

Parameters

$latitude: Latitude of marker.

$longitude: Longitude of marker.

$markername: Marker to use. '' will fall back to google's default marker.

$info: What to show in the bubble when the marker is clicked. Leave blank if you don't want a bubble.

$zoom: Map zoom. 'default' will use the default zoom from the settings page. 3 is usually a good value to use.

$width: Map width. 'default' will use the default width from the settings page.

$height: Map height. 'default' will use the default height from the settings page.

$autoshow: If set to TRUE, automatically show the marker bubble.

$map: Override parts of the map array. If you need to do much with this, you should probabaly be putting together the map array manually.

File

./gmap.module, line 1188
GMap -- Routines to use the Google Maps API in Drupal.

Code

function gmap_simple_map($latitude, $longitude, $markername = '', $info = '', $zoom = 'auto', $width = 'default', $height = 'default', $autoshow = FALSE, $map = array()) {
  $settings = array(
    'id' => gmap_get_auto_mapid(),
    'latitude' => $latitude,
    // Center the map
    'longitude' => $longitude,
  );
  if ($zoom != 'default') {
    $settings['zoom'] = $zoom;
  }
  if ($width != 'default') {
    $settings['width'] = $width;
  }
  if ($height != 'default') {
    $settings['height'] = $height;
  }
  $settings['markers'] = array(
    array(
      'latitude' => $latitude,
      'longitude' => $longitude,
      'markername' => $markername,
      'offset' => 0,
    ),
  );
  if (!empty($info)) {
    $settings['markers'][0]['text'] = $info;
  }
  if ($autoshow) {
    $settings['markers'][0]['autoclick'] = TRUE;
  }
  if (!empty($map)) {
    $settings = array_merge($settings, $map);
  }
  return theme('gmap', array(
    '#settings' => $settings,
  ));
}