You are here

function geofield_ymap_library in Geofield Yandex Maps 7

Implements hook_library().

File

./geofield_ymap.module, line 58

Code

function geofield_ymap_library() {
  $module_path = geofield_ymap_get_module_path();
  $settings = array(
    'geofieldYmap' => array(
      'modulePath' => base_path() . $module_path,
      'objectPreset' => variable_get('geofield_ymap_object_preset', ''),
    ),
  );
  $script_url = '//api-maps.yandex.ru/2.1/?lang=ru-RU&coordorder=longlat';
  $script_url .= '&apikey=' . variable_get('geofield_ymap_api_key', '');
  if (variable_get('geofield_ymap_debug_mode', FALSE)) {
    $script_url .= '&mode=debug';
  }
  $library = array(
    'geofield_ymap' => array(
      'title' => 'Geofield Yandex Maps',
      'version' => '1',
      'js' => array(
        array(
          'data' => $settings,
          'type' => 'setting',
        ),
        array(
          'data' => $script_url,
          'type' => 'external',
        ),
        array(
          'data' => $module_path . '/js/geofield_ymap.js',
        ),
      ),
      'css' => array(
        array(
          'data' => $module_path . '/geofield_ymap.css',
        ),
      ),
    ),
  );
  if ($presets_path = variable_get('geofield_ymap_presets_path', '')) {
    $library['geofield_ymap']['js'][] = array(
      'data' => $presets_path,
    );
  }
  return $library;
}