0

Using ol-cesium and want to enable 3d view of map. 2D map extent works great, but not in 3d. could not see any extent parameter on generating olcs map object. Anyone could help to extent?

Here is jsfiddle example: https://jsfiddle.net/j7rptwao/2/

<!DOCTYPE html>
<html>
  <head>
    <title>Ol-Cesium base example</title>
    <link rel="stylesheet" href="http://www.3daysofprogramming.com/playground/pg.css" type="text/css">
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL,Map,Set,Promise"></script>
    <link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.2.0/css/ol.css">
    <script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.2.0/build/ol.js"></script>
    <script src="https://openlayers.org/ol-cesium/node_modules/@camptocamp/cesium/Build/Cesium/Cesium.js"></script>
    <script src="https://openlayers.org/ol-cesium/olcesium.js"></script>
    <style>
      /**
        * Create a position for the map
        * on the page */
      #map {
        width: 100%;
        height: 100%;
      }
    </style>
  </head>
  <body>
    <div id="container" class="main">
      <div id="map"></div>
    </div>
    <button id="toggle">Toggle Cesium</button>
    <script>
      var raster = new ol.layer.Tile({
        source: new ol.source.OSM()
      });

      var map = new ol.Map({
        layers: [raster],
        target: 'map',
        view: new ol.View({
          center: [-11000000, 4600000],
          extent: [-572513.341856, 5211017.966314, 916327.095083, 6636950.728974],
          zoom: 8
        }),
      });

      var ol3d = new olcs.OLCesium({map: map, }); // map is the ol.Map instance

      var show = true;
      ol3d.setEnabled(show);

      var btn = document.querySelector('#toggle');
      btn.addEventListener('click', function () {
        show = !show;
        ol3d.setEnabled(show);
      });

    </script>
  </body>
</html>
Niru
  • 221
  • 1
  • 4
  • 12
  • Since OpenLayers 5 view constraints can be overridden by code (such as that used to synchronise OL and cesium) you will probably need to wait until a release of ol-cesium which is compatible with OpenLayers 6 (the development work for that has been done https://github.com/openlayers/ol-cesium/pull/714 ) – Mike Oct 09 '19 at 09:50
  • Can i use as beta, Or i have to wait? Is it possible to get cesium object of ol-cesium object, maybe then i can modify the extent? – Niru Oct 09 '19 at 10:11
  • OpenLayers 6.0.0 has a full release 2 weeks ago but there is no beta available for ol-cesium. I tried OL6 in your jsfiddle and the current ol-cesium isn't compatible, so I think you will need to wait. If the development work has been done I expect it will be released soon. – Mike Oct 09 '19 at 10:25
  • You know when it will be released? Still waiting. – Niru Oct 25 '19 at 12:18
  • There is a download available https://github.com/openlayers/ol-cesium/releases – Mike Oct 25 '19 at 13:06

0 Answers0