window.app - ol3 - cesium

时间:2017-03-03 12:07:16

标签: 3d openlayers cesium

我有一个关于使用Window.app和OL3Cesium的问题。 我的代码看起来像这样

window.app = {};
var app = window.app;

var measuring = false;
app.MeasureControl = function(opt_options) {
  var options = opt_options || {};
  var button = document.createElement('button');
  button.innerHTML = 'M';
  var this_ = this;
  var handleMeasure = function(e) {
    if (!measuring){
        this_.getMap().addInteraction(draw);
        createHelpTooltip();
        createMeasureTooltip();
        measuring = true;
    } else {
        this_.getMap().removeInteraction(draw);
        measuring = false;
        this_.getMap().removeOverlay(helpTooltip);
        this_.getMap().removeOverlay(measureTooltip);
    }
  }
  button.addEventListener('click', handleMeasure, false);
  button.addEventListener('touchstart', handleMeasure, false);
  var element = document.createElement('div');
  element.className = 'measure ol-unselectable ol-control button';
  element.appendChild(button);
  ol.control.Control.call(this, {
    element: element,
    target: options.target
  });
};
ol.inherits(app.MeasureControl, ol.control.Control);

此应用程序可以正常运行。并且ol3d不起作用。

var ol3d = false;
app.Cesium = function(opt_options) {
  var options = opt_options || {};
  var button = document.createElement('button');
  button.innerHTML = '3D';
  var this_ = this;

  var ol3d = function(e) {
    ol3d.setEnabled(!ol3d.getEnabled(e));
    var ol3d = new olcs.OLCesium({map: ol2d});
    var scene = ol3d.getCesiumScene();
    var terrainProvider = new Cesium.CesiumTerrainProvider({
      url : '//assets.agi.com/stk-terrain/world'
    });
    scene.terrainProvider = terrainProvider;
  };
  button.addEventListener('click', ol3d, false);
  button.addEventListener('touchstart', ol3d, false);
  var element = document.createElement('div');
  element.className = 'cesium ol-unselectable ol-control button';
  element.appendChild(button);
  ol.control.Control.call(this, {
    element: element,
    target: options.target
  });
};
ol.inherits(app.Cesium, ol.control.Control);

var ol2d = new ol.Map({    
    controls: ol.control.defaults({
    attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
      collapsible: false
    })
  }).extend([
        new app.MeasureControl(),
        new app.Cesium(),
        ]),
    target: 'map',
    layers: [],
    view: new ol.View({})
});

});

并且MeasureControl工作正常,Cesium不起作用。 哪个错误?它与所有应用程序的属性相同。

0 个答案:

没有答案