goog.provide('ol.RendererHint');
goog.provide('ol.createMap');

goog.require('goog.object');
goog.require('ol.Array');
goog.require('ol.Map');
goog.require('ol.MapProperty');
goog.require('ol.Projection');
goog.require('ol.control.DblClickZoom');
goog.require('ol.control.DragPan');
goog.require('ol.control.DragZoom');
goog.require('ol.control.MouseWheelZoom');
goog.require('ol.dom');
goog.require('ol.dom.Map');
goog.require('ol.webgl');
goog.require('ol.webgl.Map');


/**
 * @define {string} Default projection code.
 */
ol.DEFAULT_PROJECTION_CODE = 'EPSG:3857';


/**
 * @define {boolean} Whether to enable DOM.
 */
ol.ENABLE_DOM = true;


/**
 * @define {boolean} Whether to enable WebGL.
 */
ol.ENABLE_WEBGL = true;


/**
 * @enum {string}
 */
ol.RendererHint = {
  DOM: 'dom',
  WEBGL: 'webgl'
};


/**
 * @type {Array.<ol.RendererHint>}}
 */
ol.DEFAULT_RENDERER_HINT = [
  ol.RendererHint.WEBGL,
  ol.RendererHint.DOM
];


/**
 * @param {!HTMLDivElement} target Target.
 * @param {Object.<string, *>=} opt_values Values.
 * @param {ol.RendererHint|Array.<ol.RendererHint>=} opt_rendererHints
 *     Renderer hints.
 * @return {ol.Map} Map.
 */
ol.createMap = function(target, opt_values, opt_rendererHints) {

  var values = {};
  if (goog.isDef(opt_values)) {
    goog.object.extend(values, opt_values);
  }

  if (!goog.object.containsKey(values, ol.MapProperty.CONTROLS)) {
    var controls = new ol.Array();
    controls.push(new ol.control.DblClickZoom());
    controls.push(new ol.control.DragZoom());
    controls.push(new ol.control.DragPan());
    controls.push(new ol.control.MouseWheelZoom());
    values[ol.MapProperty.CONTROLS] = controls;
  }

  if (!goog.object.containsKey(values, ol.MapProperty.LAYERS)) {
    values[ol.MapProperty.LAYERS] = new ol.Array();
  }

  if (!goog.object.containsKey(values, ol.MapProperty.PROJECTION)) {
    values[ol.MapProperty.PROJECTION] =
        ol.Projection.getFromCode(ol.DEFAULT_PROJECTION_CODE);
  }

  /**
   * @type {Array.<ol.RendererHint>}
   */
  var rendererHints;
  if (goog.isDef(opt_rendererHints)) {
    if (goog.isArray(opt_rendererHints)) {
      rendererHints = opt_rendererHints;
    } else {
      rendererHints = [opt_rendererHints];
    }
  } else {
    rendererHints = ol.DEFAULT_RENDERER_HINT;
  }

  var i, rendererHint;
  for (i = 0; i < rendererHints.length; ++i) {
    rendererHint = rendererHints[i];
    if (rendererHint == ol.RendererHint.DOM) {
      if (ol.ENABLE_DOM && ol.dom.isSupported()) {
        return new ol.dom.Map(target, values);
      }
    } else if (rendererHint == ol.RendererHint.WEBGL) {
      if (ol.ENABLE_WEBGL && ol.webgl.isSupported()) {
        return new ol.webgl.Map(target, values);
      }
    }
  }

  return null;

};

@@ -559,24 +559,131 @@
 SG:3857';%0A%0A%0A
+/**%0A * @define %7Bstring%7D Default user projection code.%0A */%0Aol.DEFAULT_USER_PROJECTION_CODE = 'EPSG:4326';%0A%0A%0A
 /**%0A * @defi
@@ -2067,16 +2067,208 @@
 );%0A  %7D%0A%0A
+  if (!goog.object.containsKey(values, ol.MapProperty.USER_PROJECTION)) %7B%0A    values%5Bol.MapProperty.USER_PROJECTION%5D =%0A        ol.Projection.getFromCode(ol.DEFAULT_USER_PROJECTION_CODE);%0A  %7D%0A%0A
   /**%0A  

Set default user projection to EPSG:4326