开放层3 - 命名空间“OL”启动时
问题描述:
已经宣告错误,我使用的指令从here如何开始使用开放层,我得到了错误:Namespace "ol" already declared - source ol-debug.js
和错误this.Va is not a function - source ol.js
开放层3 - 命名空间“OL”启动时
我很确定我已经在我的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);
};
答
需要声明任何的ol.js
或ol-debug.js
不是两者。这个错误来自于你正在声明它们并且它正在创建一个命名空间冲突。
'我很确定我已经包含了ol.js,ol-debug.js和ol.css'包含ol.js或ol-debug.js,不是两个都是 – pavlos
呃,那是一个难题!谢谢。 – vjjj
哈哈。 gotcha ...很高兴帮助花花公子 – pavlos