all files / ol/ plugins.js

95.24% Statements 20/21
66.67% Branches 2/3
100% Functions 4/4
95.24% Lines 20/21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74                           317×                             195×                 14× 14×       11× 11× 11×                           11×      
goog.provide('ol.plugins');
 
goog.require('ol.PluginType');
 
/**
 * The registry of map renderer plugins.
 * @type {Array<olx.MapRendererPlugin>}
 * @private
 */
ol.plugins.mapRendererPlugins_ = [];
 
 
/**
 * Get all registered map renderer plugins.
 * @return {Array<olx.MapRendererPlugin>} The registered map renderer plugins.
 */
ol.plugins.getMapRendererPlugins = function() {
  return ol.plugins.mapRendererPlugins_;
};
 
 
/**
 * The registry of layer renderer plugins.
 * @type {Array<olx.LayerRendererPlugin>}
 * @private
 */
ol.plugins.layerRendererPlugins_ = [];
 
 
/**
 * Get all registered layer renderer plugins.
 * @return {Array<olx.LayerRendererPlugin>} The registered layer renderer plugins.
 */
ol.plugins.getLayerRendererPlugins = function() {
  return ol.plugins.layerRendererPlugins_;
};
 
 
/**
 * Register a plugin.
 * @param {ol.PluginType} type The plugin type.
 * @param {*} plugin The plugin.
 */
ol.plugins.register = function(type, plugin) {
  var plugins;
  switch (type) {
    case ol.PluginType.MAP_RENDERER: {
      plugins = ol.plugins.mapRendererPlugins_;
      plugins.push(/** @type {olx.MapRendererPlugin} */ (plugin));
      break;
    }
    case ol.PluginType.LAYER_RENDERER: {
      plugins = ol.plugins.layerRendererPlugins_;
      plugins.push(/** @type {olx.LayerRendererPlugin} */ (plugin));
      break;
    }
    default: {
      throw new Error('Unsupported plugin type: ' + type);
    }
  }
};
 
 
/**
 * Register multiple plugins.
 * @param {ol.PluginType} type The plugin type.
 * @param {Array} plugins The plugins.
 */
ol.plugins.registerMultiple = function(type, plugins) {
  for (var i = 0, ii = plugins.length; i < ii; ++i) {
    ol.plugins.register(type, plugins[i]);
  }
};