open layers 3 - 命名空间“ol”在启动时已声明错误

时间:2016-07-24 23:50:25

标签: openlayers-3 google-closure-compiler

我正在使用here中有关如何开始使用开放图层的说明,我收到了错误:Namespace "ol" already declared - source ol-debug.js和错误
this.Va is not a function - source ol.js

我很确定我已经在index.html中正确地包含了ol.js,ol-debug.js和ol.css文件。

Link打开图层js和css文件。

这是ol-debug.js档案的相关部分 -

/**
 * Defines a namespace in Closure.
 *
 * A namespace may only be defined once in a codebase. It may be defined using
 * goog.provide() or goog.module().
 *
 * The presence of one or more goog.provide() calls in a file indicates
 * that the file defines the given objects/namespaces.
 * Provided symbols must not be null or undefined.
 *
 * In addition, goog.provide() creates the object stubs for a namespace
 * (for example, goog.provide("goog.foo.bar") will create the object
 * goog.foo.bar if it does not already exist).
 *
 * Build tools also scan for provide/require/module statements
 * to discern dependencies, build dependency files (see deps.js), etc.
 *
 * @see goog.require
 * @see goog.module
 * @param {string} name Namespace provided by this file in the form
 *     "goog.package.part".
 */
goog.provide = function(name) {
  if (goog.isInModuleLoader_()) {
    throw Error('goog.provide can not be used within a goog.module.');
  }
  if (!COMPILED) {
    // Ensure that the same namespace isn't provided twice.
    // A goog.module/goog.provide maps a goog.require to a specific file
    if (goog.isProvided_(name)) {
      throw Error('Namespace "' + name + '" already declared.');
    }
  }

  goog.constructNamespace_(name);
}; 

1 个答案:

答案 0 :(得分:2)

您需要声明ol.jsol-debug.js,而不是两者。该错误来自于您正在声明这两者并且正在创建命名空间冲突这一事实。