openlayers / ol-cesium

OpenLayers - Cesium integration
http://openlayers.org/ol-cesium/
BSD 2-Clause "Simplified" License
968 stars 321 forks source link

olcs.FeatureConverter is not a constructor #1165

Open measman opened 4 months ago

measman commented 4 months ago

I am new in Cesium and also olcesium but I have done my projects in openlayers but in "oldfashioned". Now I am traying to add 3d functionality to my old openlayers project using olcesium.

My code is like:

    let layerss = this.olMap.getAllLayers();
    // console.log(this.olMap.getView().getProjection());
    this.ol3d = new olcs.OLCesium({map: this.olMap}); // ol2dMap is the ol.Map instance
    const scene = this.ol3d.getCesiumScene();
    var featureConverter = new olcs.FeatureConverter(scene);
    featureConverter.olVectorLayerToCesium(layerss[5], this.olMap.getView(),scene.primitives);
    var vectorSync = new olcs.VectorSynchronizer(this.olMap, scene, featureConverter);
    vectorSync.synchronize();

but it thows error like: Uncaught TypeError: olcs.FeatureConverter is not a constructor at p.Cesium (cross_section.js?q=1.4.0_20240214_130102:134:32) at p.Start_3D (cross_section.js?q=1.4.0_20240214_130102:165:18) at crosssection_3d_enable (cross_section.js?q=1.4.0_20240214_130102:22:34)

Can you help me please. Thanks in advance.

gberaudo commented 4 months ago

Hi @measman , the "oldfashioned" way has been removed from OpenLayers documentation. For example, https://openlayers.org/doc/quickstart.html only mentions using a bundler.

Are you using a bundler?

measman commented 4 months ago

Hi @gberaudo , thank you for your reply.

No, I am not using bundler.

isn't it possible to use "oldfashioned" way now? Can you give me some example or link of any document from which I can learn how to mix these new ES modules and oldfashioned code together and run smoothly.

Thank you for you help.

gberaudo commented 4 months ago

We removed the oldfashioned build in newer versions of Ol-Cesium. The goal was to simplify the build system by focusing on modern usages.

Have you tried using a bundler? Did you encountered issues?

measman commented 4 months ago

Yes, I have tried using Vite bundler, there is no issue. But I wanted to use Ol-Cesium in my old application, I don't want to rebuild entire application again but want to add 3D capabilities with Ol-Cesium. is there any step by step tutorial to learn Ol-Cesium? Thank you for your help.

gberaudo commented 2 months ago

There is no tutorial at the moment. I agree it would be great to go beyond the getting started we currently have. This tutorial would:

If someone wants to participate to such a task please add a comment.