通过requirejs加载openlayers模块

通过requirejs加载openlayers模块,requirejs,openlayers-3,Requirejs,Openlayers 3,我正在尝试使用requirejs来加载openlayers 3模块。 我像这样加载ol3 layerswitcher库- require(["./ol3-layerswitcher"],function(layerSwitcherObj) { console.log(layerSwitcherObj); }); //在ol3 layerswitcher文件中,我必须添加ol.js依赖项,比如 require(["

我正在尝试使用requirejs来加载openlayers 3模块。 我像这样加载ol3 layerswitcher库-

require(["./ol3-layerswitcher"],function(layerSwitcherObj)
            {
                console.log(layerSwitcherObj);
            });
//在ol3 layerswitcher文件中,我必须添加ol.js依赖项,比如

 require(["./app/ol"],function(ol)
      {
         ol.control.LayerSwitcher = function(opt_options)'
           {
            // ......
           }
      });

对象ol已定义,但layerswitcherObj未定义。有人能帮我找到正确的方法吗?

require([“/app/ol]”,function(ol)
应该是
define([“/app/ol]”,function(ol)
,因为您想将所有这些内容定义为一个模块并使用它(
require
it)稍后…编辑:如果我正确理解了您的意图。@xmike谢谢!但我想做的正是,将ol3 layerswitcher作为一个模块加载,然后使用它的函数。但目前,当我需要它时,我没有定义它。但是ol.js返回一个表示其命名空间的适当对象。